aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/decl.c
diff options
context:
space:
mode:
authorMike Stump <mrs@gcc.gnu.org>1996-04-02 21:44:27 +0000
committerMike Stump <mrs@gcc.gnu.org>1996-04-02 21:44:27 +0000
commitc91a56d26688ad6ab041f1ba223a975692c9d8c3 (patch)
tree70d788069e68470c0b9d32e3194eef5d5a8bbbd9 /gcc/cp/decl.c
parentdd07092ebe8a89f603b764519b4b8b43cf3abc2e (diff)
downloadgcc-c91a56d26688ad6ab041f1ba223a975692c9d8c3.zip
gcc-c91a56d26688ad6ab041f1ba223a975692c9d8c3.tar.gz
gcc-c91a56d26688ad6ab041f1ba223a975692c9d8c3.tar.bz2
86th Cygnus<->FSF merge
From-SVN: r11654
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r--gcc/cp/decl.c45
1 files changed, 35 insertions, 10 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 10cf2a6..93585de 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -4501,12 +4501,18 @@ lookup_name_real (name, prefer_type, nonclass)
done:
if (val)
{
+ /* This should only warn about types used in qualified-ids. */
if (from_obj && from_obj != val)
{
- cp_pedwarn ("lookup of `%D' in the scope of `%#T' (`%D')",
- name, got_object, from_obj);
- cp_pedwarn (" does not match lookup in the current scope (`%D')",
- val);
+ if (looking_for_typename && TREE_CODE (from_obj) == TYPE_DECL
+ && TREE_CODE (val) == TYPE_DECL
+ && TREE_TYPE (from_obj) != TREE_TYPE (val))
+ {
+ cp_pedwarn ("lookup of `%D' in the scope of `%#T' (`%#T')",
+ name, got_object, TREE_TYPE (from_obj));
+ cp_pedwarn (" does not match lookup in the current scope (`%#T')",
+ TREE_TYPE (val));
+ }
}
if ((TREE_CODE (val) == TEMPLATE_DECL && looking_for_template)
@@ -5700,14 +5706,15 @@ shadow_tag (declspecs)
{
/* ANSI C++ June 5 1992 WP 9.5.3. Anonymous unions may not have
function members. */
+ if (TYPE_METHODS (t))
+ error ("an anonymous union cannot have function members");
+
if (TYPE_FIELDS (t))
{
tree decl = grokdeclarator (NULL_TREE, declspecs, NORMAL, 0,
NULL_TREE, NULL_TREE);
finish_anon_union (decl);
}
- else
- error ("anonymous union cannot have a function member");
}
else
{
@@ -6525,7 +6532,9 @@ cp_finish_decl (decl, init, asmspec_tree, need_pop, flags)
cp_error ("storage size of `%D' isn't constant", decl);
}
- if (!DECL_EXTERNAL (decl) && TYPE_NEEDS_DESTRUCTOR (type))
+ if (! DECL_EXTERNAL (decl) && TYPE_NEEDS_DESTRUCTOR (type)
+ /* Cleanups for static variables are handled by `finish_file'. */
+ && ! TREE_STATIC (decl))
{
int yes = suspend_momentary ();
cleanup = maybe_build_cleanup (decl);
@@ -7676,8 +7685,11 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, raises, attrli
ctype = cname;
}
- if (ctype
- && TREE_OPERAND (decl, 1) == constructor_name_full (ctype))
+ if (ctype && TREE_CODE (TREE_OPERAND (decl, 1)) == TYPE_DECL
+ && ((DECL_NAME (TREE_OPERAND (decl, 1))
+ == constructor_name_full (ctype))
+ || (DECL_NAME (TREE_OPERAND (decl, 1))
+ == constructor_name (ctype))))
TREE_OPERAND (decl, 1) = constructor_name (ctype);
next = &TREE_OPERAND (decl, 1);
decl = *next;
@@ -9030,6 +9042,9 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, raises, attrli
if (decl_context == FIELD)
{
+ if (declarator == current_class_name)
+ cp_pedwarn ("ANSI C++ forbids nested type `%D' with same name as enclosing class",
+ declarator);
decl = build_lang_decl (TYPE_DECL, declarator, type);
if (IS_SIGNATURE (current_class_type) && opaque_typedef)
SIGNATURE_HAS_OPAQUE_TYPEDECLS (current_class_type) = 1;
@@ -9064,6 +9079,12 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, raises, attrli
error ("non-object member `%s' cannot be declared mutable", name);
}
+ bad_specifiers (decl, "type", virtualp, quals != NULL_TREE,
+ inlinep, friendp, raises != NULL_TREE);
+
+ if (initialized)
+ error ("typedef declaration includes an initializer");
+
return decl;
}
@@ -10597,15 +10618,19 @@ start_enum (name)
enumtype = lookup_tag (ENUMERAL_TYPE, name, b, 1);
if (enumtype != NULL_TREE && TREE_CODE (enumtype) == ENUMERAL_TYPE)
- cp_error ("multiple definition of enum `%T'", enumtype);
+ cp_error ("multiple definition of `%#T'", enumtype);
else
{
enumtype = make_node (ENUMERAL_TYPE);
pushtag (name, enumtype, 0);
}
+ if (b->pseudo_global)
+ cp_error ("template declaration of `%#T'", enumtype);
+
if (current_class_type)
TREE_ADDRESSABLE (b->tags) = 1;
+
current_local_enum = NULL_TREE;
/* We copy this value because enumerated type constants