re PR c++/11076 (ICE with invalid base class)
authorKriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
Fri, 24 Oct 2003 14:45:52 +0000 (14:45 +0000)
committerKriang Lerdsuwanakij <lerdsuwa@gcc.gnu.org>
Fri, 24 Oct 2003 14:45:52 +0000 (14:45 +0000)
PR c++/11076
* class.c (handle_using_decl): Swap arguments of error_not_base_type.
* parser.c (cp_parser_direct_declarator): Only resolve typename for
namespace scope declarations.

* g++.dg/template/crash13.C: New test.

From-SVN: r72897

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/crash13.C [new file with mode: 0644]

index 536feec51ed7c1a0c2af1f01fdeb594cd52da4bf..0d1cd9173ad0be3616c281fb64f3bf437a7698b0 100644 (file)
@@ -1,3 +1,10 @@
+2003-10-24  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+
+       PR c++/11076
+       * class.c (handle_using_decl): Swap arguments of error_not_base_type.
+       * parser.c (cp_parser_direct_declarator): Only resolve typename for
+       namespace scope declarations.
+
 2003-10-24  Nathan Sidwell  <nathan@codesourcery.com>
 
        PR c++/12698, c++/12699, c++/12700, c++/12566
index 123d1a4ea0f7270e3c56b5cc592480f6a35c5ea7..a053956ad9ae71f382a91ee8c1c28a40b4128361 100644 (file)
@@ -1109,7 +1109,7 @@ handle_using_decl (tree using_decl, tree t)
   binfo = lookup_base (t, ctype, ba_any, NULL);
   if (! binfo)
     {
-      error_not_base_type (t, ctype);
+      error_not_base_type (ctype, t);
       return;
     }
   
index 5a0c96ebf9ebf79f1ba271e061c062237bbccdfe..9b040f557d0a9cd2dfae79727665527aa8717b41 100644 (file)
@@ -9871,7 +9871,8 @@ cp_parser_direct_declarator (cp_parser* parser,
          if (declarator == error_mark_node)
            break;
          
-         if (TREE_CODE (declarator) == SCOPE_REF)
+         if (TREE_CODE (declarator) == SCOPE_REF
+             && !current_scope ())
            {
              tree scope = TREE_OPERAND (declarator, 0);
 
index 720df2382d54d1b65118a0b4906e23bb00eab26b..7a56993777c48c0190c8fea0909b8cbcf668d28f 100644 (file)
@@ -1,3 +1,8 @@
+2003-10-24  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+
+       PR c++/11076
+       * g++.dg/template/crash13.C: New test.
+
 2003-10-24  Joseph S. Myers  <jsm@polyomino.org.uk>
 
        * gcc.dg/c99-restrict-2.c: New test.
diff --git a/gcc/testsuite/g++.dg/template/crash13.C b/gcc/testsuite/g++.dg/template/crash13.C
new file mode 100644 (file)
index 0000000..1d2a1f5
--- /dev/null
@@ -0,0 +1,18 @@
+// { dg-do compile }
+
+// Origin: Volker Reichelt <reichelt@gcc.gnu.org>
+
+// PR c++/11076: ICE for invalid access declaration containing typename.
+
+template<typename, typename T=void> struct A
+{
+    typedef A<T,T> B;
+};
+
+template <typename T> struct C
+{                              // { dg-error "not a base type" }
+    typedef typename A<T>::B X;
+    X::Y;
+};
+
+C<void> c;                     // { dg-error "instantiated" }