This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
incomplete_type_error langhook
- From: Neil Booth <neil at daikokuya dot demon dot co dot uk>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 17 Apr 2002 21:53:18 +0100
- Subject: incomplete_type_error langhook
Bootstrapped and regtested. OK to apply?
Neil.
* c-lang.c (LANG_HOOKS_INCOMPLETE_TYPE_ERROR): Redefine.
* c-tree.h (c_incomplete_type_error): New.
* c-typeck.c (require_complete_type, build_component_ref): Update.
(incomplete_type_error): Rename.
* langhooks-def.h (lhd_incomplete_type_error): New.
(LANG_HOOKS_INCOMPLETE_TYPE_ERROR): New.
(LANG_HOOKS_FOR_TYPES_INITIALIZER): Update.
* langhooks.c (lhd_incomplete_type_error): New.
* langhooks.h (struct lang_hooks_for_types): New hook.
* tree.c (size_in_bytes): Use new hook.
* tree.h (incomplete_type_error): Remove.
ada: * gigi.h (incomplete_type_error): Remove.
* utils.c (incomplete_type_error): Remove.
cp:
* call.c (build_new_method_call): Update.
* cp-lang.c (LANG_HOOKS_INCOMPLETE_TYPE_ERROR): Redefine.
* cp-tree.h (cxx_incomplete_type_error): New.
* decl.c (grokdeclarator, grokparms): Update.
* decl2.c (check_classfn): Update.
* pt.c (tsubst): Update.
* typeck.c (complete_type_or_else, expr_sizeof,
decay_conversion): Update.
* typeck2.c (incomplete_type_error): Rename.
(add_exception_specifier): Update.
f:
* com.c (incomplete_type_error): Remove.
java:
* typeck.c (incomplete_type_error): Remove.
objc:
* objc-lang.c (LANG_HOOKS_INCOMPLETE_TYPE_ERROR): Redefine.
============================================================
Index: gcc/c-lang.c
--- gcc/c-lang.c 4 Apr 2002 22:19:35 -0000 1.87
+++ gcc/c-lang.c 17 Apr 2002 20:35:49 -0000
@@ -100,6 +100,8 @@ static void c_post_options PARAMS ((void
#define LANG_HOOKS_UNSIGNED_TYPE c_common_unsigned_type
#undef LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE
#define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE c_common_signed_or_unsigned_type
+#undef LANG_HOOKS_INCOMPLETE_TYPE_ERROR
+#define LANG_HOOKS_INCOMPLETE_TYPE_ERROR c_incomplete_type_error
/* ### When changing hooks, consider if ObjC needs changing too!! ### */
============================================================
Index: gcc/c-tree.h
--- gcc/c-tree.h 3 Apr 2002 22:39:43 -0000 1.92
+++ gcc/c-tree.h 17 Apr 2002 20:35:50 -0000
@@ -250,6 +250,7 @@ extern int comptypes PARAMS ((tree, t
extern tree c_sizeof_nowarn PARAMS ((tree));
extern tree c_size_in_bytes PARAMS ((tree));
extern bool c_mark_addressable PARAMS ((tree));
+extern void c_incomplete_type_error PARAMS ((tree, tree));
extern tree build_component_ref PARAMS ((tree, tree));
extern tree build_indirect_ref PARAMS ((tree, const char *));
extern tree build_array_ref PARAMS ((tree, tree));
============================================================
Index: gcc/c-typeck.c
--- gcc/c-typeck.c 4 Apr 2002 22:19:36 -0000 1.190
+++ gcc/c-typeck.c 17 Apr 2002 20:36:10 -0000
@@ -99,7 +99,7 @@ require_complete_type (value)
if (COMPLETE_TYPE_P (type))
return value;
- incomplete_type_error (value, type);
+ c_incomplete_type_error (value, type);
return error_mark_node;
}
@@ -108,7 +108,7 @@ require_complete_type (value)
and TYPE is the type that was invalid. */
void
-incomplete_type_error (value, type)
+c_incomplete_type_error (value, type)
tree value;
tree type;
{
@@ -1163,7 +1163,7 @@ build_component_ref (datum, component)
{
if (!COMPLETE_TYPE_P (type))
{
- incomplete_type_error (NULL_TREE, type);
+ c_incomplete_type_error (NULL_TREE, type);
return error_mark_node;
}
============================================================
Index: gcc/langhooks-def.h
--- gcc/langhooks-def.h 4 Apr 2002 22:19:37 -0000 1.27
+++ gcc/langhooks-def.h 17 Apr 2002 20:36:12 -0000
@@ -57,6 +57,7 @@ extern void lhd_print_error_function PAR
const char *));
extern void lhd_set_decl_assembler_name PARAMS ((tree));
extern bool lhd_warn_unused_global_decl PARAMS ((tree));
+extern void lhd_incomplete_type_error PARAMS ((tree, tree));
/* Declarations of default tree inlining hooks. */
tree lhd_tree_inlining_walk_subtrees PARAMS ((tree *, int *,
@@ -159,6 +160,7 @@ int lhd_tree_dump_type_quals PARAMS ((
/* Types hooks. There are no reasonable defaults for most of them,
so we create a compile-time error instead. */
#define LANG_HOOKS_MAKE_TYPE make_node
+#define LANG_HOOKS_INCOMPLETE_TYPE_ERROR lhd_incomplete_type_error
#define LANG_HOOKS_FOR_TYPES_INITIALIZER { \
LANG_HOOKS_MAKE_TYPE, \
@@ -166,7 +168,8 @@ int lhd_tree_dump_type_quals PARAMS ((
LANG_HOOKS_TYPE_FOR_SIZE, \
LANG_HOOKS_UNSIGNED_TYPE, \
LANG_HOOKS_SIGNED_TYPE, \
- LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE \
+ LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE, \
+ LANG_HOOKS_INCOMPLETE_TYPE_ERROR \
}
/* Declaration hooks. */
============================================================
Index: gcc/langhooks.c
--- gcc/langhooks.c 3 Apr 2002 22:39:43 -0000 1.26
+++ gcc/langhooks.c 17 Apr 2002 20:36:13 -0000
@@ -178,6 +178,17 @@ lhd_clear_binding_stack ()
poplevel (0, 0, 0);
}
+/* Invalid use of an incomplete type. */
+void
+lhd_incomplete_type_error (value, type)
+ tree value ATTRIBUTE_UNUSED, type;
+{
+ if (TREE_CODE (type) == ERROR_MARK)
+ return;
+
+ abort ();
+}
+
/* Provide a default routine for alias sets that always returns -1. This
is used by languages that don't need to do anything special. */
============================================================
Index: gcc/langhooks.h
--- gcc/langhooks.h 4 Apr 2002 22:19:37 -0000 1.34
+++ gcc/langhooks.h 17 Apr 2002 20:36:13 -0000
@@ -96,6 +96,12 @@ struct lang_hooks_for_types
/* Return a type the same as TYPE except unsigned or signed
according to UNSIGNEDP. */
tree (*signed_or_unsigned_type) PARAMS ((int, tree));
+
+ /* This routine is called in tree.c to print an error message for
+ invalid use of an incomplete type. VALUE is the expression that
+ was used (or 0 if that isn't known) and TYPE is the type that was
+ invalid. */
+ void (*incomplete_type_error) PARAMS ((tree value, tree type));
};
/* Language hooks related to decls and the symbol table. */
============================================================
Index: gcc/tree.c
--- gcc/tree.c 3 Apr 2002 22:26:09 -0000 1.250
+++ gcc/tree.c 17 Apr 2002 20:36:22 -0000
@@ -1187,7 +1187,7 @@ size_in_bytes (type)
if (t == 0)
{
- incomplete_type_error (NULL_TREE, type);
+ (*lang_hooks.types.incomplete_type_error) (NULL_TREE, type);
return size_zero_node;
}
============================================================
Index: gcc/tree.h
--- gcc/tree.h 17 Apr 2002 01:47:21 -0000 1.328
+++ gcc/tree.h 17 Apr 2002 20:36:31 -0000
@@ -2943,10 +2943,6 @@ extern const struct attribute_spec *lang
/* Flag saying whether common language attributes are to be supported. */
extern int lang_attribute_common;
-/* In front end. */
-
-extern void incomplete_type_error PARAMS ((tree, tree));
-
/* In integrate.c */
extern void save_for_inline PARAMS ((tree));
extern void set_decl_abstract_flags PARAMS ((tree, int));
============================================================
Index: gcc/ada/gigi.h
--- gcc/ada/gigi.h 4 Apr 2002 22:19:39 -0000 1.11
+++ gcc/ada/gigi.h 17 Apr 2002 20:36:34 -0000
@@ -439,10 +439,6 @@ extern tree gnat_signed_type PARAMS ((t
UNSIGNEDP. */
extern tree gnat_signed_or_unsigned_type PARAMS ((int, tree));
-/* This routine is called in tree.c to print an error message for invalid use
- of an incomplete type. */
-extern void incomplete_type_error PARAMS ((tree, tree));
-
/* This function is called indirectly from toplev.c to handle incomplete
declarations, i.e. VAR_DECL nodes whose DECL_SIZE is zero. To be precise,
compile_file in toplev.c makes an indirect call through the function pointer
============================================================
Index: gcc/ada/utils.c
--- gcc/ada/utils.c 4 Apr 2002 07:48:44 -0000 1.16
+++ gcc/ada/utils.c 17 Apr 2002 20:36:41 -0000
@@ -685,17 +685,6 @@ init_gigi_decls (long_long_float_type, e
ggc_add_tree_root (gnat_raise_decls, ARRAY_SIZE (gnat_raise_decls));
}
-/* This routine is called in tree.c to print an error message for invalid use
- of an incomplete type. */
-
-void
-incomplete_type_error (dont_care_1, dont_care_2)
- tree dont_care_1 ATTRIBUTE_UNUSED;
- tree dont_care_2 ATTRIBUTE_UNUSED;
-{
- gigi_abort (404);
-}
-
/* This function is called indirectly from toplev.c to handle incomplete
declarations, i.e. VAR_DECL nodes whose DECL_SIZE is zero. To be precise,
compile_file in toplev.c makes an indirect call through the function pointer
============================================================
Index: gcc/cp/call.c
--- gcc/cp/call.c 13 Apr 2002 01:33:21 -0000 1.316
+++ gcc/cp/call.c 17 Apr 2002 20:36:53 -0000
@@ -4636,7 +4636,7 @@ build_new_method_call (instance, name, a
if (flags & LOOKUP_SPECULATIVELY)
return NULL_TREE;
if (!COMPLETE_TYPE_P (basetype))
- incomplete_type_error (instance_ptr, basetype);
+ cxx_incomplete_type_error (instance_ptr, basetype);
else
error ("no matching function for call to `%T::%D(%A)%#V'",
basetype, pretty_name, user_args,
============================================================
Index: gcc/cp/cp-lang.c
--- gcc/cp/cp-lang.c 4 Apr 2002 22:19:41 -0000 1.28
+++ gcc/cp/cp-lang.c 17 Apr 2002 20:36:54 -0000
@@ -134,6 +134,8 @@ static bool cxx_warn_unused_global_decl
#define LANG_HOOKS_UNSIGNED_TYPE c_common_unsigned_type
#undef LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE
#define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE c_common_signed_or_unsigned_type
+#undef LANG_HOOKS_INCOMPLETE_TYPE_ERROR
+#define LANG_HOOKS_INCOMPLETE_TYPE_ERROR cxx_incomplete_type_error
/* Each front end provides its own hooks, for toplev.c. */
const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
============================================================
Index: gcc/cp/cp-tree.h
--- gcc/cp/cp-tree.h 7 Apr 2002 06:09:25 -0000 1.705
+++ gcc/cp/cp-tree.h 17 Apr 2002 20:37:06 -0000
@@ -4373,6 +4373,7 @@ extern tree check_return_expr
build_binary_op(code, arg1, arg2, 1)
/* in typeck2.c */
+extern void cxx_incomplete_type_error PARAMS ((tree, tree));
extern tree error_not_base_type PARAMS ((tree, tree));
extern tree binfo_or_else PARAMS ((tree, tree));
extern void readonly_error PARAMS ((tree, const char *, int));
============================================================
Index: gcc/cp/decl.c
--- gcc/cp/decl.c 16 Apr 2002 03:17:57 -0000 1.897
+++ gcc/cp/decl.c 17 Apr 2002 20:38:21 -0000
@@ -11115,7 +11115,7 @@ grokdeclarator (declarator, declspecs, d
}
else
{
- incomplete_type_error (NULL_TREE, ctype);
+ cxx_incomplete_type_error (NULL_TREE, ctype);
return error_mark_node;
}
@@ -12136,7 +12136,7 @@ grokparms (first_parm)
&& !DECL_NAME (decl) && !result && !chain && !ellipsis)
/* this is a parmlist of `(void)', which is ok. */
break;
- incomplete_type_error (decl, type);
+ cxx_incomplete_type_error (decl, type);
/* It's not a good idea to actually create parameters of
type `void'; other parts of the compiler assume that a
void type terminates the parameter list. */
============================================================
Index: gcc/cp/decl2.c
--- gcc/cp/decl2.c 17 Apr 2002 17:17:53 -0000 1.529
+++ gcc/cp/decl2.c 17 Apr 2002 20:38:30 -0000
@@ -1353,7 +1353,7 @@ check_classfn (ctype, function)
{
methods = 0;
if (!COMPLETE_TYPE_P (ctype))
- incomplete_type_error (function, ctype);
+ cxx_incomplete_type_error (function, ctype);
else
error ("no `%#D' member function declared in class `%T'",
function, ctype);
============================================================
Index: gcc/cp/pt.c
--- gcc/cp/pt.c 6 Apr 2002 16:15:17 -0000 1.584
+++ gcc/cp/pt.c 17 Apr 2002 20:38:54 -0000
@@ -6810,7 +6810,7 @@ tsubst (t, args, complain, in_decl)
if (!COMPLETE_TYPE_P (ctx))
{
if (complain & tf_error)
- incomplete_type_error (NULL_TREE, ctx);
+ cxx_incomplete_type_error (NULL_TREE, ctx);
return error_mark_node;
}
}
============================================================
Index: gcc/cp/typeck.c
--- gcc/cp/typeck.c 14 Apr 2002 13:14:52 -0000 1.401
+++ gcc/cp/typeck.c 17 Apr 2002 20:39:08 -0000
@@ -171,7 +171,7 @@ complete_type_or_else (type, value)
return NULL_TREE;
else if (!COMPLETE_TYPE_P (type))
{
- incomplete_type_error (value, type);
+ cxx_incomplete_type_error (value, type);
return NULL_TREE;
}
else
@@ -1566,7 +1566,7 @@ expr_sizeof (e)
}
else if (type_unknown_p (e))
{
- incomplete_type_error (e, TREE_TYPE (e));
+ cxx_incomplete_type_error (e, TREE_TYPE (e));
return c_sizeof (char_type_node);
}
/* It's illegal to say `sizeof (X::i)' for `i' a non-static data
@@ -1648,7 +1648,7 @@ decay_conversion (exp)
if (type_unknown_p (exp))
{
- incomplete_type_error (exp, TREE_TYPE (exp));
+ cxx_incomplete_type_error (exp, TREE_TYPE (exp));
return error_mark_node;
}
============================================================
Index: gcc/cp/typeck2.c
--- gcc/cp/typeck2.c 6 Apr 2002 16:15:19 -0000 1.118
+++ gcc/cp/typeck2.c 17 Apr 2002 20:39:11 -0000
@@ -185,7 +185,7 @@ abstract_virtuals_error (decl, type)
and TYPE is the type that was invalid. */
void
-incomplete_type_error (value, type)
+cxx_incomplete_type_error (value, type)
tree value;
tree type;
{
@@ -1326,7 +1326,7 @@ add_exception_specifier (list, spec, com
}
}
else if (complain)
- incomplete_type_error (NULL_TREE, core);
+ cxx_incomplete_type_error (NULL_TREE, core);
return list;
}
============================================================
Index: gcc/f/com.c
--- gcc/f/com.c 17 Apr 2002 01:47:36 -0000 1.168
+++ gcc/f/com.c 17 Apr 2002 20:39:42 -0000
@@ -14077,21 +14077,6 @@ global_bindings_p ()
return current_binding_level == global_binding_level;
}
-/* Print an error message for invalid use of an incomplete type.
- VALUE is the expression that was used (or 0 if that isn't known)
- and TYPE is the type that was invalid. */
-
-void
-incomplete_type_error (value, type)
- tree value UNUSED;
- tree type;
-{
- if (TREE_CODE (type) == ERROR_MARK)
- return;
-
- assert ("incomplete type?!?" == NULL);
-}
-
/* Mark ARG for GC. */
static void
mark_binding_level (void *arg)
============================================================
Index: gcc/java/typeck.c
--- gcc/java/typeck.c 1 Apr 2002 20:26:17 -0000 1.47
+++ gcc/java/typeck.c 17 Apr 2002 20:39:43 -0000
@@ -166,18 +166,6 @@ convert_to_boolean (type, expr)
return build1 (NOP_EXPR, type, expr);
}
-/* Print an error message for invalid use of an incomplete type.
- VALUE is the expression that was used (or 0 if that isn't known)
- and TYPE is the type that was invalid. */
-
-void
-incomplete_type_error (value, type)
- tree value ATTRIBUTE_UNUSED;
- tree type ATTRIBUTE_UNUSED;
-{
- error ("internal error - use of undefined type");
-}
-
/* Return a data type that has machine mode MODE.
If the mode is an integer,
then UNSIGNEDP selects between signed and unsigned types. */
============================================================
Index: gcc/objc/objc-lang.c
--- gcc/objc/objc-lang.c 4 Apr 2002 22:19:58 -0000 1.16
+++ gcc/objc/objc-lang.c 17 Apr 2002 20:39:43 -0000
@@ -97,6 +97,8 @@ static void objc_post_options
#define LANG_HOOKS_UNSIGNED_TYPE c_common_unsigned_type
#undef LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE
#define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE c_common_signed_or_unsigned_type
+#undef LANG_HOOKS_INCOMPLETE_TYPE_ERROR
+#define LANG_HOOKS_INCOMPLETE_TYPE_ERROR c_incomplete_type_error
/* Each front end provides its own hooks, for toplev.c. */
const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;