https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97175
--- Comment #6 from Martin Sebor <msebor at gcc dot gnu.org> --- It definitely would be a step in the right direction. But I'm not sure how feasible it is to turn any of these tests into compile-time. They often test different bits in different structures. For example, the location macros: (gdb) info macro DECL_SOURCE_LOCATION Defined at /src/gcc/master/gcc/tree.h:2437 included at /src/gcc/master/gcc/builtins.c:30 #define DECL_SOURCE_LOCATION(NODE) (DECL_MINIMAL_CHECK (NODE)->decl_minimal.locus) (gdb) info macro EXPR_LOCATION Defined at /src/gcc/master/gcc/tree.h:1176 included at /src/gcc/master/gcc/builtins.c:30 #define EXPR_LOCATION(NODE) (CAN_HAVE_LOCATION_P ((NODE)) ? (NODE)->exp.locus : UNKNOWN_LOCATION) In GCC, everything is an instance of tree_node (pointed-to by the NODE argument above), a union of a bunch of different data structures that represent the most common elements of a program (like a declaration, a type, a constant, etc.). Except for a small common subset of leading members the structures have a different layout, with the same thing (such as a location) sometimes being represented by different sets of bits. So decl_minimal.locus is at a different offset from the beginning of tree_node than exp.locus. Some of these bits may even be beyond the end of the union (in sort of a "flexible array member.") The only way to tell what is what and where things are is to query bits in the same position (typically the tree_code enum). I suspect changing this basic structure would amount to essentially rewriting the whole compiler. What might be doable with much less effort, though, is replacing all (or at least some of) these awful macros with more general inline functions. The location macros could be replaced (or supplanted) with: inline location_t get_location (cons_tree t) { if (DECL_P (t)) return DECL_SOURCE_LOCATION (t); if (EXPR_P (t && EXPR_HAS_LOCATION (t)) return EXPR_LOCATION (t); return UNKNOWN_LOCATION; } Some might argue that the function too should abort if t is neither a DECL nor EXPR. Others might object that using the function instead of either macro is wasteful when the caller "knows" that they're working with one or the other. But it might be worth at least proposing it.