OSDN Git Service

* pt.c (finish_member_template_decl): Deal more gracefully with
authormmitchell <mmitchell@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 4 Mar 1998 11:33:01 +0000 (11:33 +0000)
committermmitchell <mmitchell@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 4 Mar 1998 11:33:01 +0000 (11:33 +0000)
invalid declarations.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@18399 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 54b45e1..0140891 100644 (file)
@@ -1,3 +1,8 @@
+Wed Mar  4 11:28:08 1998  Mark Mitchell  <mmitchell@usa.net>
+
+       * pt.c (finish_member_template_decl): Deal more gracefully with
+       invalid declarations.
+
 Tue Mar  3 01:38:17 1998  Jason Merrill  <jason@yorick.cygnus.com>
 
        * call.c, class.c, cp-tree.h, cvt.c, decl.c, init.c, lex.c,
index dcc1373..f467897 100644 (file)
@@ -118,14 +118,21 @@ finish_member_template_decl (template_parameters, decl)
        }
       return NULL_TREE;
     }
-  else if (DECL_TEMPLATE_INFO (decl) &&
-          !DECL_TEMPLATE_SPECIALIZATION (decl))
+  else if (DECL_TEMPLATE_INFO (decl))
     {
-      check_member_template (DECL_TI_TEMPLATE (decl));
-      return DECL_TI_TEMPLATE (decl);
-    }
+      if (!DECL_TEMPLATE_SPECIALIZATION (decl))
+       {
+         check_member_template (DECL_TI_TEMPLATE (decl));
+         return DECL_TI_TEMPLATE (decl);
+       }
+      else
+       return decl;
+    } 
+  else
+    cp_error ("invalid member template declaration `%D'", decl);
+       
 
-  return decl;
+  return error_mark_node;
 }
 
 /* Returns the template nesting level of the indicated class TYPE.
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp71.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp71.C
new file mode 100644 (file)
index 0000000..f3b72be
--- /dev/null
@@ -0,0 +1,6 @@
+// Build don't link:
+
+class A
+{
+  template<class T>T epsilon; // ERROR - invalid member template
+}; // ERROR - the compiler crashes here