Adjust some panic messages accordingly.
#include <stdlib.h>
#include "config.h"
-static inline __attribute__((noreturn))
-void panic(const char *msg)
-{ fprintf(stderr, "Panic: %s\n", msg); abort(); }
+static inline __attribute__((noreturn)) void panic(char const *const file, int const line, char const *const func, char const *const msg)
+{
+ fprintf(stderr, "%s:%d: panic in %s: %s\n", file, line, func, msg);
+ abort();
+}
+
+#define panic(msg) panic(__FILE__, __LINE__, __func__, (msg))
#endif
case EXPR_ERROR:
return EXPR_CLASS_ERROR;
}
- panic("invalid expression found (is constant expression)");
+ panic("invalid expression");
}
void init_ast(void)
case ENTITY_LOCAL_LABEL:
break;
}
- panic("declaration_is_definition called on non-declaration");
+ panic("entity is not a declaration");
}
/**
break;
default:
- panic("Invalid literal kind found");
+ panic("invalid literal kind");
}
dbg_info *dbgi = get_dbg_info(&literal->base.source_position);
}
default:
- panic("Invalid literal kind found");
+ panic("invalid literal kind");
}
dbg_info *dbgi = get_dbg_info(&literal->base.source_position);
panic("not implemented reference type");
}
- panic("reference to declaration with unknown type found");
+ panic("reference to declaration with unknown type");
}
static ir_node *reference_expression_to_firm(const reference_expression_t *ref)
case BUILTIN_LIBC_CHECK:
panic("builtin did not produce an entity");
}
- panic("invalid builtin found");
+ panic("invalid builtin");
}
/**
store_value = result;
break;
default:
- panic("no incdec expr in create_incdec");
+ panic("no incdec expr");
}
set_value_for_expression_addr(value_expr, store_value, addr);
default:
break;
}
- panic("invalid UNEXPR type found");
+ panic("invalid unary expression type");
}
/**
tc = real_type_class;
goto make_const;
}
- panic("Unexpected atomic type in classify_type_to_firm().");
+ panic("Unexpected atomic type.");
}
case TYPE_COMPLEX: tc = complex_type_class; goto make_const;
case TYPE_ERROR:
break;
}
- panic("unexpected TYPE classify_type_to_firm().");
+ panic("unexpected type.");
}
make_const:;
case EXPR_ERROR: break;
}
- panic("invalid expression found");
+ panic("invalid expression");
}
/**
{
if (path->invalid) {
/* TODO: handle this... */
- panic("invalid initializer in ast2firm (excessive elements)");
+ panic("invalid initializer (excessive elements)");
}
type_path_entry_t *top = get_type_path_top(path);
return create_ir_initializer_value(&initializer->value);
case INITIALIZER_DESIGNATOR:
- panic("unexpected designator initializer found");
+ panic("unexpected designator initializer");
}
panic("unknown initializer");
}
}
}
- panic("invalid IR_INITIALIZER found");
+ panic("invalid ir_initializer");
}
static void create_dynamic_initializer(ir_initializer_t *initializer,
case STORAGE_CLASS_TYPEDEF:
break;
}
- panic("invalid storage class found");
+ panic("invalid storage class");
}
static void create_local_declarations(entity_t *e)
return NULL;
}
- case STATEMENT_ERROR: panic("error statement found");
+ case STATEMENT_ERROR: panic("error statement");
}
panic("statement not implemented");
}
/* TODO */
return false;
}
- panic("Unknown argument type found");
+ panic("unknown argument type");
}
static bool attribute_arguments_equal(const attribute_argument_t *args1,
case ENTITY_NAMESPACE: return "namespace";
}
- panic("Invalid entity kind encountered in get_entity_kind_name");
+ panic("invalid entity kind");
}
/**
case ATOMIC_TYPE_FLOAT: return 'f';
case ATOMIC_TYPE_DOUBLE: return 'd';
}
- panic("invalid atomic type in mangler");
+ panic("invalid atomic type");
}
static void mangle_atomic_type(const atomic_type_t *type)
case TYPE_TYPEDEF:
case TYPE_TYPEOF:
- panic("is_type_incomplete called without typerefs skipped");
+ panic("typedef not skipped");
}
- panic("invalid type found");
+ panic("invalid type");
}
bool is_type_object(const type_t *type)
return true;
case TYPE_TYPEDEF:
case TYPE_TYPEOF:
- panic("typerefs not skipped in compatible types?!?");
+ panic("typeref not skipped");
}
}
case TYPE_TYPEOF:
return get_type_size(type->typeoft.typeof_type);
}
- panic("invalid type in get_type_size");
+ panic("invalid type");
}
unsigned get_type_alignment(type_t *type)
case TYPE_TYPEOF:
return get_type_alignment(type->typeoft.typeof_type);
}
- panic("invalid type in get_type_alignment");
+ panic("invalid type");
}
/**
case TYPE_TYPEOF:
return get_type_modifiers(type->typeoft.typeof_type);
}
- panic("invalid type found in get_type_modifiers");
+ panic("invalid type");
}
type_qualifiers_t get_type_qualifier(const type_t *type, bool skip_array_type)
walk_entity((entity_t*)type->enumt.enume, env);
return;
}
- panic("invalid type found");
+ panic("invalid type");
}
static void walk_expression(expression_t *const expr,
case ENTITY_LOCAL_LABEL:
return;
}
- panic("invalid entity found");
+ panic("invalid entity");
}
static void walk_declarations(entity_t* entity,
fputc('!', out);
break;
default:
- panic("unimeplemented unary expression found");
+ panic("unimplemented unary expression");
}
write_expression(expression->value);
}
case TYPE_ERROR:
case TYPE_TYPEOF:
case TYPE_TYPEDEF:
- panic("invalid type found");
+ panic("invalid type");
case TYPE_ARRAY:
case TYPE_REFERENCE:
case TYPE_FUNCTION:
write_expression(expression->value);
return;
default:
- panic("unimeplemented unary expression found");
+ panic("unimplemented unary expression");
}
write_expression(expression->value);
}