summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ast/ast.cpp9
-rw-r--r--src/ast/crate.cpp4
-rw-r--r--src/ast/expr.cpp11
-rw-r--r--src/ast/path.cpp10
-rw-r--r--src/ast/path.hpp6
-rw-r--r--src/include/debug.hpp9
-rw-r--r--src/parse/lex.cpp52
-rw-r--r--src/parse/tokentree.hpp2
-rw-r--r--src/serialise.cpp4
-rw-r--r--src/span.cpp4
-rw-r--r--src/types.hpp11
11 files changed, 70 insertions, 52 deletions
diff --git a/src/ast/ast.cpp b/src/ast/ast.cpp
index 88897f57..850c1dc3 100644
--- a/src/ast/ast.cpp
+++ b/src/ast/ast.cpp
@@ -241,6 +241,7 @@ SERIALISE_TYPE(Impl::, "AST_Impl", {
::std::ostream& operator<<(::std::ostream& os, const UseStmt& x)
{
+ os << "Use(" << x.path << ")";
return os;
}
@@ -545,7 +546,9 @@ SERIALISE_TYPE_A(EnumVariant::, "AST_EnumVariant", {
})
SERIALISE_TYPE(EnumVariantData::, "AST_EnumVariantData", {
// TODO: Serialise AST::EnumVariantData
+ (void)s;
},{
+ (void)s;
})
SERIALISE_TYPE(Enum::, "AST_Enum", {
@@ -593,15 +596,21 @@ SERIALISE_TYPE(Struct::, "AST_Struct", {
})
SERIALISE_TYPE(StructData::, "AST_StructData", {
// TODO: AST::StructData serialise
+ (void)s;
},{
+ (void)s;
})
SERIALISE_TYPE(StructItem::, "AST_StructItem", {
// TODO: AST::StructItem serialise
+ (void)s;
},{
+ (void)s;
})
SERIALISE_TYPE(TupleItem::, "AST_TupleItem", {
// TODO: AST::TupleItem serialise
+ (void)s;
},{
+ (void)s;
})
::std::ostream& operator<<(::std::ostream& os, const TypeParam& tp)
diff --git a/src/ast/crate.cpp b/src/ast/crate.cpp
index 43279c90..699bd288 100644
--- a/src/ast/crate.cpp
+++ b/src/ast/crate.cpp
@@ -311,7 +311,7 @@ ExternCrate::ExternCrate()
ExternCrate::ExternCrate(const char *path)
{
- throw ParseError::Todo("Load extern crate from a file");
+ throw ParseError::Todo( FMT("Load extern crate from a file - '" << path << "'") );
}
// Fill runtime-generated structures in the crate
@@ -352,7 +352,9 @@ const MacroRules* ExternCrate::find_macro_rules(const ::std::string& name)
}
SERIALISE_TYPE(ExternCrate::, "AST_ExternCrate", {
+ (void)s;
},{
+ (void)s;
})
diff --git a/src/ast/expr.cpp b/src/ast/expr.cpp
index a2f9cbd1..675c26b8 100644
--- a/src/ast/expr.cpp
+++ b/src/ast/expr.cpp
@@ -234,7 +234,7 @@ NODE(ExprNode_Loop, {
s.item(m_cond);
s.item(m_code);
},{
- //os << "LOOP [" << m_label << "] " << m_pattern << " in/= " << m_cond << " " << m_code;
+ os << "LOOP [" << m_label << "] " << m_pattern << " in/= " << *m_cond << " " << *m_code;
})
SERIALISE_TYPE_A(ExprNode_Match_Arm::, "ExprNode_Match_Arm", {
@@ -592,10 +592,10 @@ NV(ExprNode_IfLet,
UNINDENT();
})
-NV(ExprNode_Integer, {})
-NV(ExprNode_Float, {})
-NV(ExprNode_Bool, {})
-NV(ExprNode_String, {})
+NV(ExprNode_Integer, {(void)node;})
+NV(ExprNode_Float, {(void)node;})
+NV(ExprNode_Bool, {(void)node;})
+NV(ExprNode_String, {(void)node;})
NV(ExprNode_Closure,
{
@@ -620,6 +620,7 @@ NV(ExprNode_Tuple,
})
NV(ExprNode_NamedValue,
{
+ (void)node;
// LEAF
})
diff --git a/src/ast/path.cpp b/src/ast/path.cpp
index fb1e60cf..9cdf0317 100644
--- a/src/ast/path.cpp
+++ b/src/ast/path.cpp
@@ -203,12 +203,12 @@ void Path::bind_variable(unsigned int slot)
void Path::bind_module(const Module& mod) {
m_binding = PathBinding::make_Module({&mod});
}
-void Path::bind_enum(const Enum& ent, const ::std::vector<TypeRef>& args)
+void Path::bind_enum(const Enum& ent, const ::std::vector<TypeRef>& /*args*/)
{
DEBUG("Bound to enum");
m_binding = PathBinding::make_Enum({&ent});
}
-void Path::bind_enum_var(const Enum& ent, const ::std::string& name, const ::std::vector<TypeRef>& args)
+void Path::bind_enum_var(const Enum& ent, const ::std::string& name, const ::std::vector<TypeRef>& /*args*/)
{
unsigned int idx = 0;
for( idx = 0; idx < ent.variants().size(); idx ++ )
@@ -230,7 +230,7 @@ void Path::bind_enum_var(const Enum& ent, const ::std::string& name, const ::std
DEBUG("Bound to enum variant '" << name << "' (#" << idx << ")");
m_binding = PathBinding::make_EnumVar({&ent, idx});
}
-void Path::bind_struct(const Struct& ent, const ::std::vector<TypeRef>& args)
+void Path::bind_struct(const Struct& ent, const ::std::vector<TypeRef>& /*args*/)
{
//if( args.size() > 0 )
//{
@@ -244,7 +244,7 @@ void Path::bind_struct(const Struct& ent, const ::std::vector<TypeRef>& args)
DEBUG("Bound to struct");
m_binding = PathBinding::make_Struct({&ent});
}
-void Path::bind_struct_member(const Struct& ent, const ::std::vector<TypeRef>& args, const PathNode& member_node)
+void Path::bind_struct_member(const Struct& ent, const ::std::vector<TypeRef>& /*args*/, const PathNode& member_node)
{
DEBUG("Binding to struct item. This needs to be deferred");
m_binding = PathBinding::make_StructMethod({&ent, member_node.name()});
@@ -253,7 +253,7 @@ void Path::bind_static(const Static& ent)
{
m_binding = PathBinding::make_Static({&ent});
}
-void Path::bind_trait(const Trait& ent, const ::std::vector<TypeRef>& args)
+void Path::bind_trait(const Trait& ent, const ::std::vector<TypeRef>& /*args*/)
{
m_binding = PathBinding::make_Trait({&ent});
}
diff --git a/src/ast/path.hpp b/src/ast/path.hpp
index 462ab946..65d65159 100644
--- a/src/ast/path.hpp
+++ b/src/ast/path.hpp
@@ -224,8 +224,8 @@ public:
nodes().back().args() = b[0].args();
else if( b[0].args().size() > 0 )
throw ::std::runtime_error("add_tail to empty path, but generics in source");
- else
- ;
+ else {
+ }
for(unsigned int i = 1; i < b_r.nodes.size(); i ++)
nodes().push_back(b_r.nodes[i]);
m_binding = PathBinding();
@@ -344,9 +344,11 @@ public:
void bind_static(const Static& ent);
void bind_trait(const Trait& ent, const ::std::vector<TypeRef>& args={});
void bind_function(const Function& ent, const ::std::vector<TypeRef>& args={}) {
+ (void)args;
m_binding = PathBinding::make_Function({&ent});
}
void bind_type_alias(const TypeAlias& ent, const ::std::vector<TypeRef>& args={}) {
+ (void)args;
m_binding = PathBinding::make_TypeAlias({&ent});
}
diff --git a/src/include/debug.hpp b/src/include/debug.hpp
index e1dedb7b..9dafdb42 100644
--- a/src/include/debug.hpp
+++ b/src/include/debug.hpp
@@ -13,7 +13,7 @@ extern int g_debug_indent_level;
#else
#define INDENT() do { } while(0)
#define UNINDENT() do {} while(0)
-#define DEBUG(ss) do{ } while(0)
+#define DEBUG(ss) do{ (void)(::NullSink() << ss); } while(0)
#endif
extern bool debug_enabled();
@@ -31,6 +31,13 @@ struct RepeatLitStr
}
};
+class NullSink:
+ public ::std::ostream
+{
+public:
+ NullSink() {}
+};
+
class TraceLog
{
const char* m_tag;
diff --git a/src/parse/lex.cpp b/src/parse/lex.cpp
index 7cf5ad76..b0fbed9a 100644
--- a/src/parse/lex.cpp
+++ b/src/parse/lex.cpp
@@ -31,12 +31,13 @@ Lexer::Lexer(::std::string filename):
{
throw ::std::runtime_error("Unable to open file");
}
+ // Consume the BOM
if( this->getc() == '\xef' )
{
- if( this->getc() != '\xbb' )
- ;
- if( this->getc() != '\xbf' )
- ;
+ if( this->getc() != '\xbb' ) {
+ }
+ if( this->getc() != '\xbf' ) {
+ }
m_line_ofs = 0;
}
else
@@ -805,8 +806,8 @@ uint32_t Lexer::parseEscape(char enclosing)
this->ungetc();
else if( ch != '}' )
throw ParseError::Generic(*this, "Expected terminating } in \\u sequence");
- else
- ;
+ else {
+ }
return val; }
case '0':
return '\0';
@@ -982,28 +983,23 @@ struct EscapedString {
friend ::std::ostream& operator<<(::std::ostream& os, const EscapedString& x) {
for(auto b : x.s) {
- if( b < 0 || b >= 128 ) {
- os << b;
- }
- else {
- switch(b)
- {
- case '"':
- os << "\\\"";
- break;
- case '\\':
- os << "\\\\";
- break;
- case '\n':
- os << "\\n";
- break;
- default:
- if( ' ' <= b && b < 0x7F )
- os << b;
- else
- os << "\\u{" << ::std::hex << (unsigned int)b << "}";
- break;
- }
+ switch(b)
+ {
+ case '"':
+ os << "\\\"";
+ break;
+ case '\\':
+ os << "\\\\";
+ break;
+ case '\n':
+ os << "\\n";
+ break;
+ default:
+ if( ' ' <= b && b < 0x7F )
+ os << b;
+ else
+ os << "\\u{" << ::std::hex << (unsigned int)b << "}";
+ break;
}
}
return os;
diff --git a/src/parse/tokentree.hpp b/src/parse/tokentree.hpp
index 1dacbd9b..fddefdd1 100644
--- a/src/parse/tokentree.hpp
+++ b/src/parse/tokentree.hpp
@@ -23,7 +23,7 @@ public:
bool is_token() const {
return m_tok.type() != TOK_NULL;
}
- const unsigned int size() const {
+ unsigned int size() const {
return m_subtrees.size();
}
const TokenTree& operator[](unsigned int idx) const {
diff --git a/src/serialise.cpp b/src/serialise.cpp
index fc662b4f..5c57da9f 100644
--- a/src/serialise.cpp
+++ b/src/serialise.cpp
@@ -42,7 +42,7 @@ void Serialiser_TextTree::start_object(const char *tag) {
m_os << tag << " {\n";
indent();
}
-void Serialiser_TextTree::end_object(const char *_tag) {
+void Serialiser_TextTree::end_object(const char * /*tag*/) {
unindent();
print_indent();
m_os << "}\n";
@@ -253,7 +253,7 @@ void Deserialiser_TextTree::start_object(const char *tag)
if( c != '{' )
throw DeserialiseFailure("start_object", "no {");
}
-void Deserialiser_TextTree::end_object(const char *tag)
+void Deserialiser_TextTree::end_object(const char * /*tag*/)
{
eat_ws();
char c = getc();
diff --git a/src/span.cpp b/src/span.cpp
index b720b263..8a60b07a 100644
--- a/src/span.cpp
+++ b/src/span.cpp
@@ -45,13 +45,13 @@ void Span::bug(::std::function<void(::std::ostream&)> msg) const
}
void Span::error(ErrorType tag, ::std::function<void(::std::ostream&)> msg) const {
- ::std::cerr << this->filename << ":" << this->start_line << ": error:";
+ ::std::cerr << this->filename << ":" << this->start_line << ": error:" << tag <<":";
msg(::std::cerr);
::std::cerr << ::std::endl;
abort();
}
void Span::warning(WarningType tag, ::std::function<void(::std::ostream&)> msg) const {
- ::std::cerr << this->filename << ":" << this->start_line << ": warning:";
+ ::std::cerr << this->filename << ":" << this->start_line << ": warning:" << tag << ":";
msg(::std::cerr);
::std::cerr << ::std::endl;
//abort();
diff --git a/src/types.hpp b/src/types.hpp
index 2c59e8b6..6db45937 100644
--- a/src/types.hpp
+++ b/src/types.hpp
@@ -125,6 +125,7 @@ public:
}
TypeRef(Span sp=Span()):
+ m_span( mv$(sp) ),
m_data(TypeData::make_Any({}))
{}
@@ -157,7 +158,7 @@ public:
{}
struct TagTuple {};
- TypeRef(TagTuple _, Span sp, ::std::vector<TypeRef> inner_types):
+ TypeRef(TagTuple , Span sp, ::std::vector<TypeRef> inner_types):
m_span(mv$(sp)),
m_data(TypeData::make_Tuple({::std::move(inner_types)}))
{}
@@ -168,22 +169,22 @@ public:
{}
struct TagReference {};
- TypeRef(TagReference _, Span sp, bool is_mut, TypeRef inner_type):
+ TypeRef(TagReference , Span sp, bool is_mut, TypeRef inner_type):
m_span(mv$(sp)),
m_data(TypeData::make_Borrow({ is_mut, ::make_unique_ptr(mv$(inner_type)) }))
{}
struct TagPointer {};
- TypeRef(TagPointer _, Span sp, bool is_mut, TypeRef inner_type):
+ TypeRef(TagPointer , Span sp, bool is_mut, TypeRef inner_type):
m_span(mv$(sp)),
m_data(TypeData::make_Pointer({ is_mut, ::make_unique_ptr(mv$(inner_type)) }))
{}
struct TagSizedArray {};
- TypeRef(TagSizedArray _, Span sp, TypeRef inner_type, ::std::shared_ptr<AST::ExprNode> size):
+ TypeRef(TagSizedArray , Span sp, TypeRef inner_type, ::std::shared_ptr<AST::ExprNode> size):
m_span(mv$(sp)),
m_data(TypeData::make_Array({ ::make_unique_ptr(mv$(inner_type)), mv$(size) }))
{}
struct TagUnsizedArray {};
- TypeRef(TagUnsizedArray _, Span sp, TypeRef inner_type):
+ TypeRef(TagUnsizedArray , Span sp, TypeRef inner_type):
m_span(mv$(sp)),
m_data(TypeData::make_Array({ ::make_unique_ptr(mv$(inner_type)), ::std::shared_ptr<AST::ExprNode>() }))
{}