re PR c++/27102 (ICE with invalid class name in function template)
authorMark Mitchell <mark@codesourcery.com>
Wed, 3 May 2006 00:19:40 +0000 (00:19 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Wed, 3 May 2006 00:19:40 +0000 (00:19 +0000)
PR c++/27102
* decl.c (grokdeclarator): Robustify checks for defining members
of incomplete types.
PR c++/27102
* g++.dg/template/crash49.C: New test.

From-SVN: r113492

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

index 803644d87904be4e6bd89d7563eafa44308581e7..1b8438cb03efdde10d791df2251c9489f8093209 100644 (file)
@@ -1,5 +1,9 @@
 2006-05-02  Mark Mitchell  <mark@codesourcery.com>
 
+       PR c++/27102
+       * decl.c (grokdeclarator): Robustify checks for defining members
+       of incomplete types.
+
        PR c++/27309
        * class.c (add_method): Call grok_special_member_properties.
        * decl.c (grokdeclarator): Don't call it here.
index 40c2120556858429ae484d6166d47c062f41d290..057c1fb51691f43e4abeb3aaa1392e41e6fa7c3d 100644 (file)
@@ -7722,12 +7722,19 @@ grokdeclarator (const cp_declarator *declarator,
       else if (/* If the qualifying type is already complete, then we
                  can skip the following checks.  */
               !COMPLETE_TYPE_P (ctype)
-              /* If a function is being defined, then the qualifying
-                 type must be complete.  The qualifying type may be
-                 incomplete for a declaration only if the qualifying
-                 type is one of the classes presently being defined,
-                 or if it is a dependent type.  */
-              && (funcdef_flag 
+              && (/* If the function is being defined, then
+                     qualifying type must certainly be complete.  */
+                  funcdef_flag 
+                  /* A friend declaration of "T::f" is OK, even if
+                     "T" is a template parameter.  But, if this
+                     function is not a friend, the qualifying type
+                     must be a class.  */
+                  || (!friendp && !CLASS_TYPE_P (ctype))
+                  /* For a declaration, the type need not be
+                     complete, if either it is dependent (since there
+                     is no meaningful definition of complete in that
+                     case) or the qualifying class is currently being
+                     defined.  */
                   || !(dependent_type_p (ctype)
                        || currently_open_class (ctype)))
               /* Check that the qualifying type is complete.  */
index 07196c89269f294ec85fc01ec96825c0ffe61c6d..a439ad29fd64c2a9fa54d3556f0106f9b3690fbb 100644 (file)
@@ -1,3 +1,8 @@
+2006-05-02  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/27102
+       * g++.dg/template/crash49.C: New test.
+
 2006-05-02  Steve Ellcey  <sje@cup.hp.com>
 
        PR testsuite/27032
diff --git a/gcc/testsuite/g++.dg/template/crash49.C b/gcc/testsuite/g++.dg/template/crash49.C
new file mode 100644 (file)
index 0000000..41fc9be
--- /dev/null
@@ -0,0 +1,4 @@
+// PR c++/27102
+
+template <typename T>
+void T::foo; // { dg-error "invalid" }