From f5b76e275ca0c4480cbfff365e43f771f48128b0 Mon Sep 17 00:00:00 2001
From: lmillward <lmillward@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Thu, 21 Sep 2006 18:33:49 +0000
Subject: [PATCH]         PR c++/28303         * decl.c (grokdeclarator):
 Return error_mark_node on         declaration with two or more data types.

        * g++.dg/template/typedef6.C: New test.
        * g++.dg/init/error1.C: Adjust error markers.
        * g++.dg/parse/crash9.C: Likewise.
        * g++.dg/template/crash55.C: Likewise.



git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@117118 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/cp/ChangeLog                         | 4 ++++
 gcc/cp/decl.c                            | 6 +++++-
 gcc/testsuite/ChangeLog                  | 6 ++++++
 gcc/testsuite/g++.dg/init/error1.C       | 2 +-
 gcc/testsuite/g++.dg/template/crash55.C  | 2 +-
 gcc/testsuite/g++.dg/template/typedef6.C | 8 ++++++++
 6 files changed, 25 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/template/typedef6.C

diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index fce58ed98e31..f6b83bd78945 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -3,6 +3,10 @@
 	PR c++/28861
 	* decl.c (shadow_tag): Return error_mark_node
         if maybe_process_partial_specialization failed.
+
+	PR c++/28303
+        * decl.c (grokdeclarator): Return error_mark_node on
+        declaration with two or more data types.
 	
 2006-09-20  Danny Smith  <dannysmith@users.sourceforge.net>
 
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 1d83aa32fd77..7b932c05b1ec 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -7117,7 +7117,11 @@ grokdeclarator (const cp_declarator *declarator,
   /* If there were multiple types specified in the decl-specifier-seq,
      issue an error message.  */
   if (declspecs->multiple_types_p)
-    error ("two or more data types in declaration of %qs", name);
+    {
+      error ("two or more data types in declaration of %qs", name);
+      return error_mark_node;
+    }
+
   /* Extract the basic type from the decl-specifier-seq.  */
   type = declspecs->type;
   if (type == error_mark_node)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f1be2adaf8f6..49ea82513864 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -3,6 +3,12 @@
         PR c++/28861
         * g++.dg/template/spec32.C: New test.
         * g++.dg/parse/crash9.C: Adjust error markers.
+
+	PR c++/28303
+        * g++.dg/template/typedef6.C: New test.
+        * g++.dg/init/error1.C: Adjust error markers.
+        * g++.dg/parse/crash9.C: Likewise.
+        * g++.dg/template/crash55.C: Likewise.
 	
 2006-09-21  Janis Johnson  <janis187@us.ibm.com>
 
diff --git a/gcc/testsuite/g++.dg/init/error1.C b/gcc/testsuite/g++.dg/init/error1.C
index e930fc75c5e9..dd12e4cca43d 100644
--- a/gcc/testsuite/g++.dg/init/error1.C
+++ b/gcc/testsuite/g++.dg/init/error1.C
@@ -1,7 +1,7 @@
 // PR c++/12696
 
 struct A {
-  static float b[10]; // { dg-error "" }
+  static float b[10];
 }
 
 float A::b[] = {1,2,3}; // { dg-error "" }
diff --git a/gcc/testsuite/g++.dg/template/crash55.C b/gcc/testsuite/g++.dg/template/crash55.C
index 0e3fe4c3a593..377603dcff3d 100644
--- a/gcc/testsuite/g++.dg/template/crash55.C
+++ b/gcc/testsuite/g++.dg/template/crash55.C
@@ -1,6 +1,6 @@
 //PR c++/27668
 
 template<typename class T, T = T()> // { dg-error "nested-name-specifier|two or more|valid type" }
-struct A {};                        // { dg-error "definition"
+struct A {};                        // { dg-error "definition|template" }
 
 template<int> void foo(A<int>);     // { dg-error "mismatch|constant|template argument" }
diff --git a/gcc/testsuite/g++.dg/template/typedef6.C b/gcc/testsuite/g++.dg/template/typedef6.C
new file mode 100644
index 000000000000..cd2db634a2b0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/typedef6.C
@@ -0,0 +1,8 @@
+//PR c++/28303
+
+template<typename T> struct A
+{
+  typedef struct typename T::X X;       // { dg-error "expected identifier|two or more" }
+};
+
+template<typename T> A<T>::X::X() {}    // { dg-error "not a type|forbids declaration" }
-- 
GitLab