diff options
Diffstat (limited to 'gcc/tree.c')
-rw-r--r-- | gcc/tree.c | 133 |
1 files changed, 82 insertions, 51 deletions
@@ -5077,81 +5077,112 @@ get_set_constructor_bytes (init, buffer, wd_size) #ifdef ENABLE_CHECKING -/* Complain if the tree code does not match the expected one. - NODE is the tree node in question, CODE is the expected tree code, - and FILE and LINE are the filename and line number, respectively, - of the line on which the check was done. If NONFATAL is nonzero, - don't abort if the reference is invalid; instead, return 0. - If the reference is valid, return NODE. */ +#if defined __GNUC__ && (__GNUC__ > 2 || __GNUC_MINOR__ > 6) -tree -tree_check (node, code, file, line, nofatal) - tree node; +/* Complain that the tree code of NODE does not match the expected CODE. + FILE, LINE, and FUNCTION are of the caller. + + FIXME: should print the blather about reporting the bug. */ +void +tree_check_failed (node, code, file, line, function) + const tree node; enum tree_code code; const char *file; int line; - int nofatal; + const char *function; { - if (TREE_CODE (node) == code) - return node; - else if (nofatal) - return 0; - else - fatal ("%s:%d: Expect %s, have %s\n", file, line, - tree_code_name[code], tree_code_name[TREE_CODE (node)]); + fatal ("Internal compiler error in `%s', at %s:%d:\n\ +\texpected %s, have %s\n", + function, trim_filename (file), line, + tree_code_name[code], tree_code_name[TREE_CODE (node)]); } /* Similar to above, except that we check for a class of tree code, given in CL. */ - -tree -tree_class_check (node, cl, file, line, nofatal) - tree node; +void +tree_class_check_failed (node, cl, file, line, function) + const tree node; char cl; const char *file; int line; - int nofatal; + const char *function; { - if (TREE_CODE_CLASS (TREE_CODE (node)) == cl) + fatal ("Internal compiler error in `%s', at %s:%d:\n\ +\texpected '%c', have '%c' (%s)\n", + function, trim_filename (file), line, cl, + TREE_CODE_CLASS (TREE_CODE (node)), + tree_code_name[TREE_CODE (node)]); +} + +#else /* not gcc or old gcc */ + +/* These functions are just like the above, but they have to + do the check as well as report the error. */ +tree +tree_check (node, code, file, line) + const tree node; + enum tree_code code; + const char *file; + int line; +{ + if (TREE_CODE (node) == code) return node; - else if (nofatal) - return 0; - else - fatal ("%s:%d: Expect '%c', have '%s'\n", file, line, - cl, tree_code_name[TREE_CODE (node)]); + + fatal ("Internal compiler error at %s:%d:\n\texpected %s, have %s\n", + file, trim_filename (file), tree_code_name[code], tree_code_name[TREE_CODE(node)]); } -/* Likewise, but complain if the tree node is not an expression. */ +tree +tree_class_check (node, class, file, line) + const tree node; + char class; + const char *file; + int line; +{ + if (TREE_CODE_CLASS (TREE_CODE (node)) == class) + return node; + + fatal ("Internal compiler error at %s:%d:\n\ +\texpected '%c', have '%c' (%s)\n", + file, trim_filename (file), class, TREE_CODE_CLASS (TREE_CODE (node)), + tree_code_name[TREE_CODE(node)]); +} tree -expr_check (node, ignored, file, line, nofatal) - tree node; - int ignored; +cst_or_constructor_check (node, file, line) + const tree node; const char *file; int line; - int nofatal; { - switch (TREE_CODE_CLASS (TREE_CODE (node))) - { - case 'r': - case 's': - case 'e': - case '<': - case '1': - case '2': - break; + enum tree_code code = TREE_CODE (node); + + if (code == CONSTRUCTOR || TREE_CODE_CLASS (code) == 'c') + return node; - default: - if (nofatal) - return 0; - else - fatal ("%s:%d: Expect expression, have '%s'\n", file, line, - tree_code_name[TREE_CODE (node)]); - } + fatal ("Internal compiler error at %s:%d:\n\ +\texpected constructor, have %s\n", + file, line, tree_code_name[code]); +} - return node; +tree +cst_or_constructor_check (node, file, line) + const tree node; + const char *file; + int line; +{ + char c = TREE_CODE_CLASS (TREE_CODE (node)); + + if (c == 'r' || c == 's' || c == '<' + || c == '1' || c == '2' || c == 'e') + return node; + + fatal ("Internal compiler error at %s:%d:\n\ +\texpected 'e', have '%c' (%s)\n", + file, trim_filename (file), c, tree_code_name[TREE_CODE (node)]); } -#endif + +#endif /* not gcc or old gcc */ +#endif /* ENABLE_CHECKING */ /* Return the alias set for T, which may be either a type or an expression. */ |