Rename "PREV" to "NOTE". Bump of version.

This commit is contained in:
Christoffer Lerno
2022-08-11 11:17:48 +02:00
parent ac7823cabb
commit d4c1a08fcd
9 changed files with 30 additions and 33 deletions

View File

@@ -1967,7 +1967,7 @@ Path *path_create_from_string(const char *string, uint32_t len, SourceSpan span)
#define SEMA_ERROR_HERE(...) sema_error_at(c->span, __VA_ARGS__)
#define SEMA_ERROR_LAST(...) sema_error_at(c->prev_span, __VA_ARGS__)
#define SEMA_ERROR(_node, ...) sema_error_at((_node)->span, __VA_ARGS__)
#define SEMA_PREV(_node, ...) sema_error_prev_at((_node)->span, __VA_ARGS__)
#define SEMA_NOTE(_node, ...) sema_error_prev_at((_node)->span, __VA_ARGS__)
#define EXPAND_EXPR_STRING(str_) (str_)->const_expr.string.len, (str_)->const_expr.string.chars
#define TABLE_MAX_LOAD 0.5

View File

@@ -10,7 +10,7 @@
typedef enum
{
PRINT_TYPE_ERROR,
PRINT_TYPE_PREV,
PRINT_TYPE_NOTE,
PRINT_TYPE_WARN
} PrintType;
@@ -27,8 +27,8 @@ static void print_error(SourceSpan location, const char *message, PrintType prin
case PRINT_TYPE_ERROR:
eprintf("Error|%s|%d|%s\n", file->name, location.row, message);
return;
case PRINT_TYPE_PREV:
eprintf("Note|%s|%d|%s\n", file->name, location.row, message);
case PRINT_TYPE_NOTE:
// Note should not be passed on.
return;
case PRINT_TYPE_WARN:
eprintf("Warning|%s|%d|%s\n", file->name, location.row, message);
@@ -116,7 +116,7 @@ static void print_error(SourceSpan location, const char *message, PrintType prin
case PRINT_TYPE_ERROR:
eprintf("(%s:%d:%d) Error: %s\n\n", file->full_path, location.row, col_location, message);
break;
case PRINT_TYPE_PREV:
case PRINT_TYPE_NOTE:
eprintf("(%s:%d:%d) Note: %s\n\n", file->full_path, location.row, col_location, message);
break;
case PRINT_TYPE_WARN:
@@ -133,7 +133,7 @@ static void print_error(SourceSpan location, const char *message, PrintType prin
case PRINT_TYPE_ERROR:
eprintf("(%s:%d) Error: %s\n\n", file->full_path, location.row, message);
break;
case PRINT_TYPE_PREV:
case PRINT_TYPE_NOTE:
eprintf("(%s:%d) Note: %s\n\n", file->full_path, location.row, message);
break;
case PRINT_TYPE_WARN:
@@ -186,13 +186,10 @@ void sema_error_prev_at(SourceSpan loc, const char *message, ...)
#define MAX_ERROR_LEN 4096
char buffer[MAX_ERROR_LEN];
size_t written = vsnprintf(buffer, MAX_ERROR_LEN - 1, message, args);
if (written > MAX_ERROR_LEN - 2)
// Ignore errors
if (written <= MAX_ERROR_LEN - 2)
{
print_error(loc, "<Error message was too long>", PRINT_TYPE_PREV);
}
else
{
print_error(loc, buffer, PRINT_TYPE_PREV);
print_error(loc, buffer, PRINT_TYPE_NOTE);
}
va_end(args);
return;

View File

@@ -1838,7 +1838,7 @@ static inline Decl *parse_fault_declaration(ParseContext *c, Visibility visibili
if (other_constant->name == name)
{
SEMA_ERROR(fault_const, "This fault value was declared twice.");
SEMA_PREV(other_constant, "The previous declaration was here.");
SEMA_NOTE(other_constant, "The previous declaration was here.");
decl_poison(fault_const);
break;
}
@@ -1937,7 +1937,7 @@ static inline Decl *parse_enum_declaration(ParseContext *c, Visibility visibilit
if (other_constant->name == name)
{
SEMA_ERROR(enum_const, "This enum constant is declared twice.");
SEMA_PREV(other_constant, "The previous declaration was here.");
SEMA_NOTE(other_constant, "The previous declaration was here.");
decl_poison(enum_const);
break;
}

View File

@@ -58,7 +58,7 @@ static inline bool sema_check_no_duplicate_parameter(Decl **decls, Decl *current
if (name == decls[i]->name)
{
SEMA_ERROR(current, "Duplicate parameter name %s.", name);
SEMA_PREV(decls[i], "Previous use of the name was here.");
SEMA_NOTE(decls[i], "Previous use of the name was here.");
decl_poison(decls[i]);
decl_poison(current);
return false;
@@ -79,7 +79,7 @@ static inline bool sema_analyse_struct_member(SemaContext *context, Decl *parent
if (other)
{
SEMA_ERROR(decl, "Duplicate member name '%s'.", other->name);
SEMA_PREV(other, "Previous declaration was here.");
SEMA_NOTE(other, "Previous declaration was here.");
return false;
}
if (decl->name) sema_add_member(context, decl);
@@ -519,7 +519,7 @@ static inline bool sema_analyse_bitstruct_member(SemaContext *context, Decl *dec
if (member->name == other_member->name)
{
SEMA_ERROR(member, "Duplicate members with the name '%s'.", member->name);
SEMA_PREV(other_member, "The other member was declared here.");
SEMA_NOTE(other_member, "The other member was declared here.");
return false;
}
// And possibly overlap.
@@ -530,7 +530,7 @@ static inline bool sema_analyse_bitstruct_member(SemaContext *context, Decl *dec
&& start_bit <= other_member->var.end_bit)
{
SEMA_ERROR(member, "Overlapping members, please use '@overlap' if this is intended.");
SEMA_PREV(other_member, "The other member was declared here.");
SEMA_NOTE(other_member, "The other member was declared here.");
return false;
}
}
@@ -1110,7 +1110,7 @@ static inline bool unit_add_method_like(CompilationUnit *unit, Type *parent_type
if (method)
{
SEMA_ERROR(method_like, "This %s is already defined in this module.", name_by_decl(method_like));
SEMA_PREV(method, "The previous definition was here.");
SEMA_NOTE(method, "The previous definition was here.");
return false;
}
Decl *ambiguous = NULL;
@@ -1119,7 +1119,7 @@ static inline bool unit_add_method_like(CompilationUnit *unit, Type *parent_type
if (method)
{
SEMA_ERROR(method_like, "This %s is already defined for '%s'.", name_by_decl(method_like), parent_type->name);
SEMA_PREV(method, "The previous definition was here.");
SEMA_NOTE(method, "The previous definition was here.");
return false;
}
if (method_like->operator && !sema_check_operator_method_validity(method_like)) return false;
@@ -1799,7 +1799,7 @@ static inline bool sema_analyse_main_function(SemaContext *context, Decl *decl)
if (global_context.main)
{
SEMA_ERROR(function, "Duplicate main functions found.");
SEMA_PREV(global_context.main, "The first one was found here.");
SEMA_NOTE(global_context.main, "The first one was found here.");
}
else
{

View File

@@ -1748,7 +1748,7 @@ static inline Type *unify_returns(SemaContext *context)
{
SEMA_ERROR(return_stmt, "Cannot find a common parent type of %s and %s",
rtype, common_type);
SEMA_PREV(context->returns[i - 1], "The previous return was here.");
SEMA_NOTE(context->returns[i - 1], "The previous return was here.");
return NULL;
}
@@ -6097,7 +6097,7 @@ static inline bool sema_take_addr_of_var(Expr *expr, Decl *decl)
if (!decl->var.type_info)
{
SEMA_ERROR(expr, "The constant is not typed, either type it or use && to take the reference to a temporary.");
SEMA_PREV(decl, "The constant was defined here.");
SEMA_NOTE(decl, "The constant was defined here.");
return false;
}
assert(decl->type != type_void);

View File

@@ -245,7 +245,7 @@ static inline bool sema_analyse_top_level_switch(SemaContext *context, Decl *ct_
if (expr_const_in_range(const_expr, other_const, other_const_to))
{
SEMA_ERROR(kase, "'%s' appears more than once.", expr_const_to_error_string(const_expr));
SEMA_PREV(cases[j]->ct_case_decl.expr, "The previous $case was here.");
SEMA_NOTE(cases[j]->ct_case_decl.expr, "The previous $case was here.");
return false;
}
}
@@ -259,7 +259,7 @@ static inline bool sema_analyse_top_level_switch(SemaContext *context, Decl *ct_
if (default_case < case_count)
{
SEMA_ERROR(kase, "More than one $default is not allowed.");
SEMA_PREV(cases[default_case], "The previous $default was here.");
SEMA_NOTE(cases[default_case], "The previous $default was here.");
return false;
}
default_case = (int)i;

View File

@@ -1486,7 +1486,7 @@ static bool sema_analyse_nextcase_stmt(SemaContext *context, Ast *statement)
if (cond->type->canonical != type_typeid)
{
SEMA_ERROR(statement, "Unexpected 'type' in as an 'nextcase' destination.");
SEMA_PREV(statement, "The 'switch' here uses expected a type '%s'.", type_to_error_string(cond->type));
SEMA_NOTE(statement, "The 'switch' here uses expected a type '%s'.", type_to_error_string(cond->type));
return false;
}
cases = parent->switch_stmt.cases;
@@ -1695,7 +1695,7 @@ static inline bool sema_check_type_case(SemaContext *context, Type *switch_type,
if (other_expr->expr_kind == EXPR_CONST && other_expr->const_expr.typeid == my_type)
{
SEMA_ERROR(case_stmt, "The same type appears more than once.");
SEMA_PREV(other, "Here is the case with that type.");
SEMA_NOTE(other, "Here is the case with that type.");
return false;
}
}
@@ -1762,7 +1762,7 @@ static inline bool sema_check_value_case(SemaContext *context, Type *switch_type
if (expr_const_in_range(const_expr, other_const, other_to_const))
{
SEMA_ERROR(case_stmt, "The same case value appears more than once.");
SEMA_PREV(other, "Here is the previous use of that value.");
SEMA_NOTE(other, "Here is the previous use of that value.");
return false;
}
}
@@ -1819,7 +1819,7 @@ static bool sema_analyse_switch_body(SemaContext *context, Ast *statement, Sourc
if (default_case)
{
SEMA_ERROR(stmt, "'default' may only appear once in a single 'switch', please remove one.");
SEMA_PREV(default_case, "Here is the previous use.");
SEMA_NOTE(default_case, "Here is the previous use.");
success = false;
}
default_case = stmt;
@@ -1946,7 +1946,7 @@ static bool sema_analyse_ct_switch_body(SemaContext *context, Ast *statement)
if (expr_const_in_range(const_expr, other_const, other_const_to))
{
SEMA_ERROR(stmt, "'%s' appears more than once.", expr_const_to_error_string(const_expr));
SEMA_PREV(cases[j]->case_stmt.expr, "The previous $case was here.");
SEMA_NOTE(cases[j]->case_stmt.expr, "The previous $case was here.");
return false;
}
}
@@ -1960,7 +1960,7 @@ static bool sema_analyse_ct_switch_body(SemaContext *context, Ast *statement)
if (default_case < case_count)
{
SEMA_ERROR(stmt, "More than one $default is not allowed.");
SEMA_PREV(cases[default_case], "The previous $default was here.");
SEMA_NOTE(cases[default_case], "The previous $default was here.");
return false;
}
default_case = (int)i;

View File

@@ -8,7 +8,7 @@
void sema_shadow_error(Decl *decl, Decl *old)
{
SEMA_ERROR(decl, "'%s' would shadow a previous declaration.", decl->name);
SEMA_PREV(old, "The previous use of '%s' was here.", decl->name);
SEMA_NOTE(old, "The previous use of '%s' was here.", decl->name);
}
bool sema_resolve_type_info_maybe_inferred(SemaContext *context, TypeInfo *type_info, bool allow_inferred_type)

View File

@@ -1 +1 @@
#define COMPILER_VERSION "0.3.11"
#define COMPILER_VERSION "0.3.12"