summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-03-09 11:03:02 +0800
committerJohn Hodge <tpg@mutabah.net>2016-03-09 11:03:02 +0800
commit0571d0f4741106bcb43b512a66747e582b12ead7 (patch)
tree4169252b0488f1e5159fcdbda11dd337ac8d25e0
parent782f8d212ef07c9c236282f244827530db00eed7 (diff)
downloadmrust-0571d0f4741106bcb43b512a66747e582b12ead7.tar.gz
Resolve - Bug when unexpanded macro encountered
-rw-r--r--Makefile2
-rw-r--r--src/ast/ast.hpp4
-rw-r--r--src/convert/resolve.cpp2
-rw-r--r--src/include/span.hpp10
-rw-r--r--src/span.cpp18
5 files changed, 29 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index 68841755..c97be0e0 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@ V ?= @
LINKFLAGS := -g
LIBS :=
-CXXFLAGS := -g -Wall -std=c++11 -Werror
+CXXFLAGS := -g -Wall -std=c++14 -Werror
#CXXFLAGS += -O3
CPPFLAGS := -I src/include/ -I src/
diff --git a/src/ast/ast.hpp b/src/ast/ast.hpp
index c0ab4b2f..504d3704 100644
--- a/src/ast/ast.hpp
+++ b/src/ast/ast.hpp
@@ -291,7 +291,7 @@ class ImplDef:
TypeRef m_type;
public:
ImplDef() {}
- ImplDef(ImplDef&&) noexcept = default;
+ ImplDef(ImplDef&&) /*noexcept*/ = default;
ImplDef(MetaItems attrs, GenericParams params, Path trait_type, TypeRef impl_type):
m_attrs( move(attrs) ),
m_params( move(params) ),
@@ -329,7 +329,7 @@ class Impl:
::std::vector< ::std::pair< ::std::vector<TypeRef>, Impl > > m_concrete_impls;
public:
Impl() {}
- Impl(Impl&&) noexcept = default;
+ Impl(Impl&&) /*noexcept*/ = default;
Impl(MetaItems attrs, GenericParams params, TypeRef impl_type, Path trait_type):
m_def( move(attrs), move(params), move(trait_type), move(impl_type) )
{}
diff --git a/src/convert/resolve.cpp b/src/convert/resolve.cpp
index 6640193a..9587eb51 100644
--- a/src/convert/resolve.cpp
+++ b/src/convert/resolve.cpp
@@ -211,7 +211,7 @@ public:
}
void visit(AST::ExprNode_Macro& node) {
- throw ParseError::Todo("Resolve-time expanding of macros");
+ BUG(node.get_pos(), "Un-resolved macro in expression");
//MacroExpander expanded_macro = Macro_Invoke(node.m_name.c_str(), node.m_tokens);
// TODO: Requires being able to replace the node with a completely different type of node
diff --git a/src/include/span.hpp b/src/include/span.hpp
index 49169e5b..05417a83 100644
--- a/src/include/span.hpp
+++ b/src/include/span.hpp
@@ -17,6 +17,8 @@ enum WarningType
W0000,
};
+class Position;
+
struct ProtoSpan
{
::std::string filename;
@@ -40,6 +42,8 @@ struct Span
end_line(end_line),
end_ofs(end_ofs)
{}
+ Span(const Span& x);
+ Span(const Position& position);
Span():
filename("")/*,
start_line(0), start_ofs(0),
@@ -59,7 +63,7 @@ struct Spanned
T m_item;
};
-#define ERROR(span, code, msg) do { (span).error(code, [&](::std::ostream& os) { os << msg; }); throw ::std::runtime_error("Error fell through" #code); } while(0)
-#define BUG(span, msg) do { (span).bug([&](::std::ostream& os) { os << msg; }); throw ::std::runtime_error("Bug fell through"); } while(0)
-#define TODO(span, msg) do { (span).bug([&](::std::ostream& os) { os << "TODO: " << msg; }); throw ::std::runtime_error("Bug (todo) fell through"); } while(0)
+#define ERROR(span, code, msg) do { ::Span(span).error(code, [&](::std::ostream& os) { os << msg; }); throw ::std::runtime_error("Error fell through" #code); } while(0)
+#define BUG(span, msg) do { ::Span(span).bug([&](::std::ostream& os) { os << msg; }); throw ::std::runtime_error("Bug fell through"); } while(0)
+#define TODO(span, msg) do { ::Span(span).bug([&](::std::ostream& os) { os << "TODO: " << msg; }); throw ::std::runtime_error("Bug (todo) fell through"); } while(0)
diff --git a/src/span.cpp b/src/span.cpp
index e3458c8b..5216976d 100644
--- a/src/span.cpp
+++ b/src/span.cpp
@@ -8,6 +8,24 @@
#include <functional>
#include <iostream>
#include <span.hpp>
+#include <parse/lex.hpp>
+
+Span::Span(const Span& x):
+ filename(x.filename),
+ start_line(x.start_line),
+ start_ofs(x.start_ofs),
+ end_line(x.end_line),
+ end_ofs(x.end_ofs)
+{
+}
+Span::Span(const Position& pos):
+ filename(pos.filename.c_str()),
+ start_line(pos.line),
+ start_ofs(pos.ofs),
+ end_line(pos.line),
+ end_ofs(pos.ofs)
+{
+}
void Span::bug(::std::function<void(::std::ostream&)> msg) const
{