decl.c (grokdeclarator): Diagnose undefined template contexts.
authorNathan Sidwell <nathan@codesourcery.com>
Tue, 28 Nov 2000 10:18:25 +0000 (10:18 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Tue, 28 Nov 2000 10:18:25 +0000 (10:18 +0000)
cp:
* decl.c (grokdeclarator): Diagnose undefined template contexts.
testsuite:
* g++.old-deja/g++.pt/incomplete1.C: New test.

From-SVN: r37815

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.old-deja/g++.pt/incomplete1.C [new file with mode: 0644]

index fa0940110aaaab5d8c099c38cdfe60bfb2ffa857..7f18e81350ce5181a38fd6f5ba16913931cd01b0 100644 (file)
@@ -1,3 +1,7 @@
+2000-11-28  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * decl.c (grokdeclarator): Diagnose undefined template contexts.
+
 2000-11-28  Nathan Sidwell  <nathan@codesourcery.com>
 
        * decl.c (grokdeclarator): Do type access control on friend
index da74687aa1a59a5b85cea9a6967065db6c55fc3a..1c29bbf949c8343f0e2c3e59fe9f8bde042b42da 100644 (file)
@@ -10995,8 +10995,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
                  }
                else if (TREE_CODE (type) == FUNCTION_TYPE)
                  {
-                   if (current_class_type == NULL_TREE
-                       || friendp)
+                   if (current_class_type == NULL_TREE || friendp)
                      type = build_cplus_method_type (ctype, TREE_TYPE (type),
                                                      TYPE_ARG_TYPES (type));
                    else
@@ -11022,18 +11021,11 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
                      }
                    type = build_offset_type (ctype, type);
                  }
-               else if (uses_template_parms (ctype))
-                 {
-                    if (TREE_CODE (type) == FUNCTION_TYPE)
-                     type
-                       = build_cplus_method_type (ctype, TREE_TYPE (type),
-                                                  TYPE_ARG_TYPES (type));
-                 }
                else
-                 {
-                   cp_error ("structure `%T' not yet defined", ctype);
-                   return error_mark_node;
-                 }
+                 {
+                   incomplete_type_error (NULL_TREE, ctype);
+                   return error_mark_node;
+                 }
 
                declarator = sname;
              }
index 66e472321a2b6b41dfdbcb2b335644f6f3845ffa..f827bf055e24eef1d18732a3a65af3d9f2cc3a66 100644 (file)
@@ -1,3 +1,7 @@
+2000-11-28  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * g++.old-deja/g++.pt/incomplete1.C: New test.
+
 2000-11-28  Nathan Sidwell  <nathan@codesourcery.com>
 
        * g++.old-deja/g++.other/friend9.C: New test.
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/incomplete1.C b/gcc/testsuite/g++.old-deja/g++.pt/incomplete1.C
new file mode 100644 (file)
index 0000000..c08e90c
--- /dev/null
@@ -0,0 +1,11 @@
+// Build don't link:
+
+// Copyright (C) 2000 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 28 Nov 2000 <nathan@codesourcery.com>
+
+// Inspired by by 756. We'd ICE when trying to define a member of an
+// incomplete template type.
+
+template<class X> struct ObjCount;  // ERROR - forward decl
+
+template<class X> int ObjCount<X>::m; // ERROR - undefined type