flag for this because "A union for which objects or pointers are
declared is not an anonymous union" [class.union]. */
#define ANON_AGGR_TYPE_P(NODE) \
- (TYPE_LANG_SPECIFIC (NODE) \
- && TYPE_LANG_SPECIFIC (NODE)->type_flags.anon_aggr)
+ (CLASS_TYPE_P (NODE) && TYPE_LANG_SPECIFIC (NODE)->type_flags.anon_aggr)
#define SET_ANON_AGGR_TYPE_P(NODE) \
(TYPE_LANG_SPECIFIC (NODE)->type_flags.anon_aggr = 1)
extern int currently_open_class PROTO((tree));
extern tree get_vfield_offset PROTO((tree));
extern void duplicate_tag_error PROTO((tree));
-extern tree finish_struct PROTO((tree, tree, int));
-extern void finish_struct_1 PROTO((tree, int));
+extern tree finish_struct PROTO((tree, tree));
+extern void finish_struct_1 PROTO((tree));
extern int resolves_to_fixed_type_p PROTO((tree, int *));
extern void init_class_processing PROTO((void));
extern int is_empty_class PROTO((tree));
if (! (TREE_CODE (newdecl) == FUNCTION_DECL
&& olddecl != NULL_TREE
&& TREE_CODE (olddecl) == FUNCTION_DECL
- && (DECL_BUILT_IN (olddecl)
- || DECL_BUILT_IN_NONANSI (olddecl))))
+ && DECL_ARTIFICIAL (olddecl)))
{
cp_pedwarn (IDENTIFIER_IMPLICIT_DECL (name)
? implicit_extern_static_warning
/* Check for redeclaration and other discrepancies. */
if (TREE_CODE (olddecl) == FUNCTION_DECL
- && DECL_ARTIFICIAL (olddecl)
- && (DECL_BUILT_IN (olddecl) || DECL_BUILT_IN_NONANSI (olddecl)))
- {
- /* If you declare a built-in or predefined function name as static,
- the old definition is overridden, but optionally warn this was a
- bad choice of name. Ditto for overloads. */
- if (! TREE_PUBLIC (newdecl)
- || (TREE_CODE (newdecl) == FUNCTION_DECL
- && DECL_LANGUAGE (newdecl) != DECL_LANGUAGE (olddecl)))
- {
- if (warn_shadow)
- cp_warning ("shadowing %s function `%#D'",
- DECL_BUILT_IN (olddecl) ? "built-in" : "library",
+ && DECL_ARTIFICIAL (olddecl))
+ {
+ if (TREE_CODE (newdecl) != FUNCTION_DECL)
+ {
+ /* If you declare a built-in or predefined function name as static,
+ the old definition is overridden, but optionally warn this was a
+ bad choice of name. */
+ if (! TREE_PUBLIC (newdecl))
+ {
+ if (warn_shadow)
+ cp_warning ("shadowing %s function `%#D'",
+ DECL_BUILT_IN (olddecl) ? "built-in" : "library",
+ olddecl);
+ /* Discard the old built-in function. */
+ return 0;
+ }
+ /* If the built-in is not ansi, then programs can override
+ it even globally without an error. */
+ else if (! DECL_BUILT_IN (olddecl))
+ cp_warning ("library function `%#D' redeclared as non-function `%#D'",
+ olddecl, newdecl);
+ else
+ {
+ cp_error ("declaration of `%#D'", newdecl);
+ cp_error ("conflicts with built-in declaration `%#D'",
olddecl);
- /* Discard the old built-in function. */
+ }
return 0;
}
- else if (! types_match)
+ else if (!types_match)
{
- if (TREE_CODE (newdecl) != FUNCTION_DECL)
+ if ((DECL_LANGUAGE (newdecl) == lang_c
+ && DECL_LANGUAGE (olddecl) == lang_c)
+ || compparms (TYPE_ARG_TYPES (TREE_TYPE (newdecl)),
+ TYPE_ARG_TYPES (TREE_TYPE (olddecl))))
{
- /* If the built-in is not ansi, then programs can override
- it even globally without an error. */
- if (! DECL_BUILT_IN (olddecl))
- cp_warning ("library function `%#D' redeclared as non-function `%#D'",
- olddecl, newdecl);
- else
+ /* A near match; override the builtin. */
+
+ if (TREE_PUBLIC (newdecl))
{
- cp_error ("declaration of `%#D'", newdecl);
- cp_error ("conflicts with built-in declaration `%#D'",
- olddecl);
+ cp_warning ("new declaration `%#D'", newdecl);
+ cp_warning ("ambiguates built-in declaration `%#D'",
+ olddecl);
}
- return 0;
+ else if (warn_shadow)
+ cp_warning ("shadowing %s function `%#D'",
+ DECL_BUILT_IN (olddecl) ? "built-in" : "library",
+ olddecl);
}
-
- cp_warning ("declaration of `%#D'", newdecl);
- cp_warning ("conflicts with built-in declaration `%#D'",
- olddecl);
+ else
+ /* Discard the old built-in function. */
+ return 0;
}
}
else if (TREE_CODE (olddecl) != TREE_CODE (newdecl))
int doing_global = (namespace_bindings_p () || !(flags & PUSH_LOCAL));
if (doing_global)
- {
- old = namespace_binding (name, DECL_CONTEXT (decl));
- if (old && TREE_CODE (old) == FUNCTION_DECL
- && DECL_ARTIFICIAL (old)
- && (DECL_BUILT_IN (old) || DECL_BUILT_IN_NONANSI (old)))
- {
- if (duplicate_decls (decl, old))
- return old;
- old = NULL_TREE;
- }
- }
+ old = namespace_binding (name, DECL_CONTEXT (decl));
else
old = lookup_name_current_level (name);
if (TREE_CODE (size) == NOP_EXPR
&& TREE_TYPE (size) == TREE_TYPE (TREE_OPERAND (size, 0)))
size = TREE_OPERAND (size, 0);
+ if (TREE_READONLY_DECL_P (size))
+ size = decl_constant_value (size);
/* If this involves a template parameter, it will be a
constant at instantiation time, but we don't know
dname);
size = integer_one_node;
}
- if (TREE_READONLY_DECL_P (size))
- size = decl_constant_value (size);
if (pedantic && integer_zerop (size))
cp_pedwarn ("ANSI C++ forbids zero-size array `%D'", dname);
if (TREE_CONSTANT (size))