This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH COMMITTED: Better error message for NON_TYPE_CHECK
- From: Ian Lance Taylor <ian at airs dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: 14 Jan 2006 00:18:18 -0800
- Subject: PATCH COMMITTED: Better error message for NON_TYPE_CHECK
I think it's annoying that a failure of NON_TYPE_CHECK produces the
error message
expected class 'type', have 'type' ...
This patch changes that error message to
did not expect class 'type', have 'type' ...
Tested with i686-pc-linux-gnu bootstrap. Committed.
Ian
2006-01-14 Ian Lance Taylor <ian@airs.com>
* tree.c (tree_not_class_check_failed): New function.
* tree.h (NON_TYPE_CHECK): Call tree_not_class_check_failed.
(tree_not_class_check_failed): Declare.
Index: tree.h
===================================================================
--- tree.h (revision 109696)
+++ tree.h (working copy)
@@ -592,8 +592,8 @@ enum tree_node_structure_enum {
#define NON_TYPE_CHECK(T) __extension__ \
({ const tree __t = (T); \
if (TYPE_P (__t)) \
- tree_class_check_failed (__t, tcc_type, __FILE__, __LINE__, \
- __FUNCTION__); \
+ tree_not_class_check_failed (__t, tcc_type, __FILE__, __LINE__, \
+ __FUNCTION__); \
__t; })
#define TREE_VEC_ELT_CHECK(T, I) __extension__ \
@@ -660,6 +660,10 @@ extern void tree_not_check_failed (const
extern void tree_class_check_failed (const tree, const enum tree_code_class,
const char *, int, const char *)
ATTRIBUTE_NORETURN;
+extern void tree_not_class_check_failed (const tree,
+ const enum tree_code_class,
+ const char *, int, const char *)
+ ATTRIBUTE_NORETURN;
extern void tree_vec_elt_check_failed (int, int, const char *,
int, const char *)
ATTRIBUTE_NORETURN;
Index: tree.c
===================================================================
--- tree.c (revision 109696)
+++ tree.c (working copy)
@@ -6012,6 +6012,21 @@ tree_class_check_failed (const tree node
TREE_CODE_CLASS_STRING (TREE_CODE_CLASS (TREE_CODE (node))),
tree_code_name[TREE_CODE (node)], function, trim_filename (file), line);
}
+
+/* Similar to tree_check_failed, except that we check that a tree does
+ not have the specified code, given in CL. */
+
+void
+tree_not_class_check_failed (const tree node, const enum tree_code_class cl,
+ const char *file, int line, const char *function)
+{
+ internal_error
+ ("tree check: did not expect class %qs, have %qs (%s) in %s, at %s:%d",
+ TREE_CODE_CLASS_STRING (cl),
+ TREE_CODE_CLASS_STRING (TREE_CODE_CLASS (TREE_CODE (node))),
+ tree_code_name[TREE_CODE (node)], function, trim_filename (file), line);
+}
+
#undef DEFTREESTRUCT
#define DEFTREESTRUCT(VAL, NAME) NAME,