Bug in lookup_fnfields

Martin von Loewis martin@mira.isdn.cs.tu-berlin.de
Fri Mar 27 15:32:00 GMT 1998


>   o Write a generic macro for checking codes, and complaining 
>     about mismatches.
> 
>   o Begin using this macro in the TREE_ macros.

I've been using

#define TREE_VALUE(NODE) (__extension__({if(TREE_CODE(NODE)!=TREE_LIST)abort();}),((NODE)->list.value))

which is quite a hack, cannot be turned off, only available from stage 2 on, 
etc.

You may want to put the check into a function, even though it
introduces an additional function call for each access. That way, you
could write

#define DEFTREECODE (code, name, type, size)   \
  int code##_CHECK (node); tree node;          \
  { if(node == NULL_TREE)                      \
     fatal("Accessing NULL_TREE");             \
    if(TREE_CODE(node)!=code)                  \
     fatal("Node %x is not a %s\n",node,type); \
    return 0;                                  \
  }

#include "tree.def"

Maybe you want to get __FILE__ and __LINE__ as well, but this would
require a macro.

Regards,
Martin



More information about the Gcc-bugs mailing list