From 081531b4928c1bd9c4aa17c6b9ab900b98ff9622 Mon Sep 17 00:00:00 2001 From: nathan Date: Fri, 18 May 2001 15:00:29 +0000 Subject: [PATCH] cp: PR c++/2526 * decl.c (pushdecl): Adjust error string. (xref_tag): Adjust friend class injection warning. Remove the inherited name from the class shadowed scope. testsuite: * g++.old-deja/g++.pt/inherit2.C: Remove XFAIL. * g++.old-deja/g++.pt/crash67.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@42265 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 6 +++++ gcc/cp/decl.c | 33 ++++++++++++++++++---------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.old-deja/g++.pt/crash67.C | 20 +++++++++++++++++ gcc/testsuite/g++.old-deja/g++.pt/inherit2.C | 4 ++-- 5 files changed, 55 insertions(+), 13 deletions(-) create mode 100644 gcc/testsuite/g++.old-deja/g++.pt/crash67.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 66540ef..0b59a1e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2001-05-18 Nathan Sidwell + + * decl.c (pushdecl): Adjust error string. + (xref_tag): Adjust friend class injection warning. Remove the + inherited name from the class shadowed scope. + 2001-05-17 Mark Mitchell * except.c (cp_protect_cleanup_actions): New function. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index ee5c279..7604401 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -3938,7 +3938,8 @@ pushdecl (x) else if (t == wchar_decl_node) { if (pedantic && ! DECL_IN_SYSTEM_HEADER (x)) - cp_pedwarn ("redeclaration of wchar_t as `%T'", TREE_TYPE (x)); + cp_pedwarn ("redeclaration of `wchar_t' as `%T'", + TREE_TYPE (x)); /* Throw away the redeclaration. */ return t; @@ -12535,16 +12536,26 @@ xref_tag (code_type_node, name, globalize) if (t && globalize && TREE_CODE (t) == TYPENAME_TYPE) { static int explained; - - cp_warning ("`%s %T' declares a new type at namespace scope;\n\ -to refer to the inherited type, say `%s %T::%T'%s", - tag_name (tag_code), name, tag_name (tag_code), - constructor_name (current_class_type), TYPE_IDENTIFIER (t), - (!explained ? "\n\ -(names from dependent base classes are not visible to unqualified name lookup)" - : "")); - - explained = 1; + tree shadowed; + + cp_warning ("`%s %T' declares a new type at namespace scope", + tag_name (tag_code), name); + if (!explained++) + cp_warning (" names from dependent base classes are not visible to unqualified name lookup - to refer to the inherited type, say `%s %T::%T'%s", + tag_name (tag_code), + constructor_name (current_class_type), + TYPE_IDENTIFIER (t)); + + /* We need to remove the class scope binding for the + TYPENAME_TYPE as otherwise poplevel_class gets confused. */ + for (shadowed = b->class_shadowed; + shadowed; + shadowed = TREE_CHAIN (shadowed)) + if (TREE_TYPE (shadowed) == TYPE_NAME (t)) + { + TREE_PURPOSE (shadowed) = NULL_TREE; + break; + } } if (t && TREE_CODE (t) != code && TREE_CODE (t) != TEMPLATE_TYPE_PARM diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 25dca8c..cdfd501 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2001-05-18 Nathan Sidwell + + * g++.old-deja/g++.pt/inherit2.C: Remove XFAIL. + * g++.old-deja/g++.pt/crash67.C: New test. + 2001-05-17 Jeffrey D. Oldham * g++.old-deja/g++.other/debug9.C: New test. diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash67.C b/gcc/testsuite/g++.old-deja/g++.pt/crash67.C new file mode 100644 index 0000000..e8fc214 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash67.C @@ -0,0 +1,20 @@ +// Build don't link: +// Special g++ Options: +// +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 6 May 2001 + +// Bug 2526. We ICE'd after diagnosing dependant name confusion in +// friendliness when not being pedantic. + +template +struct B +{ + typedef B Mother; +}; + +template +struct D : B +{ + friend class Mother; // WARNING - defines namespace class +}; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/inherit2.C b/gcc/testsuite/g++.old-deja/g++.pt/inherit2.C index 628f590..5198a64 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/inherit2.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/inherit2.C @@ -1,7 +1,7 @@ // Test that we warn about unqualified references to implicit typenames. -// Bug: g++ is confused by the binding for ::AN and crashes. + // Special g++ Options: -// excess errors test - XFAIL *-*-* +// Build don't link: template struct A { struct AA { }; -- 2.7.4