aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@yorick.cygnus.com>1999-07-21 08:52:14 +0000
committerJason Merrill <jason@gcc.gnu.org>1999-07-21 04:52:14 -0400
commit9f33663b8d400e06d2d3cb514e952db0bb1e8c4b (patch)
tree9aa23e8bb2069a014b5c9f9a1f467a297e95d461 /gcc
parentaad2312110c2d6382b4627a006b117c8876ae5f2 (diff)
downloadgcc-9f33663b8d400e06d2d3cb514e952db0bb1e8c4b.zip
gcc-9f33663b8d400e06d2d3cb514e952db0bb1e8c4b.tar.gz
gcc-9f33663b8d400e06d2d3cb514e952db0bb1e8c4b.tar.bz2
decl.c (warn_extern_redeclared_static): Check DECL_ARTIFICIAL...
* decl.c (warn_extern_redeclared_static): Check DECL_ARTIFICIAL, not DECL_BUILT_IN, to determine if a function is internally declared. (duplicate_decls): Likewise. Improve handling of builtins. (push_overloaded_decl): Remove special handling of builtins. * cp-tree.h (ANON_AGGR_TYPE_P): Use CLASS_TYPE_P. * decl.c (grokdeclarator): Pull out decl_constant_value in templates, too. * class.c (finish_struct, finish_struct_1): Remove 'warn_anon' parm. * cp-tree.h, pt.c, semantics.c: Adjust. * method.c (largest_union_member): Remove. From-SVN: r28204
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog14
-rw-r--r--gcc/cp/class.c8
-rw-r--r--gcc/cp/cp-tree.h7
-rw-r--r--gcc/cp/decl.c93
-rw-r--r--gcc/cp/method.c18
-rw-r--r--gcc/cp/pt.c2
-rw-r--r--gcc/cp/semantics.c3
7 files changed, 70 insertions, 75 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index ca7a166..7df7bab 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,19 @@
1999-07-20 Jason Merrill <jason@yorick.cygnus.com>
+ * decl.c (warn_extern_redeclared_static): Check DECL_ARTIFICIAL,
+ not DECL_BUILT_IN, to determine if a function is internally declared.
+ (duplicate_decls): Likewise. Improve handling of builtins.
+ (push_overloaded_decl): Remove special handling of builtins.
+
+ * cp-tree.h (ANON_AGGR_TYPE_P): Use CLASS_TYPE_P.
+
+ * decl.c (grokdeclarator): Pull out decl_constant_value in
+ templates, too.
+
+ * class.c (finish_struct, finish_struct_1): Remove 'warn_anon' parm.
+ * cp-tree.h, pt.c, semantics.c: Adjust.
+ * method.c (largest_union_member): Remove.
+
* lang-specs.h (c++-cpp-output): Pass -fpreprocessed.
* lex.c (token_getch, token_put_back): New fns.
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 6a25b59..41f1d79 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -3202,9 +3202,8 @@ add_fields_to_vec (fields, field_vec, idx)
ATTRIBUTES is the set of decl attributes to be applied, if any. */
void
-finish_struct_1 (t, warn_anon)
+finish_struct_1 (t)
tree t;
- int warn_anon;
{
int old;
enum tree_code code = TREE_CODE (t);
@@ -4279,9 +4278,8 @@ unreverse_member_declarations (t)
}
tree
-finish_struct (t, attributes, warn_anon)
+finish_struct (t, attributes)
tree t, attributes;
- int warn_anon;
{
/* Append the fields we need for constructing signature tables. */
if (IS_SIGNATURE (t))
@@ -4299,7 +4297,7 @@ finish_struct (t, attributes, warn_anon)
TYPE_SIZE (t) = integer_zero_node;
}
else
- finish_struct_1 (t, warn_anon);
+ finish_struct_1 (t);
TYPE_BEING_DEFINED (t) = 0;
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 07c9523..55c93ea 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -1848,8 +1848,7 @@ extern int flag_new_for_scope;
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)
@@ -2763,8 +2762,8 @@ extern void add_method PROTO((tree, tree *, tree));
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));
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 8323737..dda66fe 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -3048,8 +3048,7 @@ warn_extern_redeclared_static (newdecl, olddecl)
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
@@ -3092,44 +3091,58 @@ duplicate_decls (newdecl, olddecl)
/* 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))
@@ -4469,17 +4482,7 @@ push_overloaded_decl (decl, flags)
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);
@@ -10013,6 +10016,8 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
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
@@ -10048,8 +10053,6 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
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))
diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index caa3eb5..04f7b39 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -2180,24 +2180,6 @@ emit_thunk (thunk_fndecl)
/* Code for synthesizing methods which have default semantics defined. */
-/* For the anonymous union in TYPE, return the member that is at least as
- large as the rest of the members, so we can copy it. */
-
-static tree
-largest_union_member (type)
- tree type;
-{
- tree f, type_size = TYPE_SIZE (type);
-
- for (f = TYPE_FIELDS (type); f; f = TREE_CHAIN (f))
- if (simple_cst_equal (DECL_SIZE (f), type_size) == 1)
- return f;
-
- /* We should always find one. */
- my_friendly_abort (323);
- return NULL_TREE;
-}
-
/* Generate code for default X(X&) constructor. */
static void
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index bb48cc8..0744812 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -5183,7 +5183,7 @@ instantiate_class_template (type)
input_filename = DECL_SOURCE_FILE (typedecl);
unreverse_member_declarations (type);
- finish_struct_1 (type, 0);
+ finish_struct_1 (type);
CLASSTYPE_GOT_SEMICOLON (type) = 1;
/* Clear this now so repo_template_used is happy. */
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 059375b..b66efdf 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -1320,7 +1320,6 @@ begin_class_definition (t)
/* Don't change signatures. */
if (! IS_SIGNATURE (t))
{
- int needs_writing;
tree name = TYPE_IDENTIFIER (t);
if (! ANON_AGGRNAME_P (name))
@@ -1464,7 +1463,7 @@ finish_class_definition (t, attributes, semi, pop_scope_p)
;
else
{
- t = finish_struct (t, attributes, semi);
+ t = finish_struct (t, attributes);
if (semi)
note_got_semicolon (t);
}