This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Bug in lookup_fnfields


>   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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]