Patchwork [C++] PR 12288

login
register
mail settings
Submitter Paolo Carlini
Date May 20, 2013, 3:21 p.m.
Message ID <519A3F8F.7080000@oracle.com>
Download mbox | patch
Permalink /patch/245056/
State New
Headers show

Comments

Paolo Carlini - May 20, 2013, 3:21 p.m.
Hi,

this is also by and large fixed, but we can do a bit better in terms of 
not producing a:

error: ISO C++ forbids declaration of ‘parameter’ with no type 
[-fpermissive]

after a meaningful error. In grokdeclarator there is already a mechanism 
to suppress those, but in cp_parser_parameter_declaration we fail to 
check the return value cp_parser_parse_and_diagnose_invalid_type_name.

Tested x86_64-linux.

Thanks,
Paolo.

////////////////////////
/cp
2013-05-20  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/12288
	* parser.c (cp_parser_parameter_declaration): Check return value
	of cp_parser_parse_and_diagnose_invalid_type_name.

/testsuite
2013-05-20  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/12288
	* g++.dg/parse/error52.C: New.
	* g++.dg/parse/error3.C: Adjust.
	* g++.dg/parse/error36.C: Likewise.
Jason Merrill - May 20, 2013, 4:44 p.m.
OK.

Jason

Patch

Index: cp/parser.c
===================================================================
--- cp/parser.c	(revision 199102)
+++ cp/parser.c	(working copy)
@@ -17844,8 +17844,9 @@  cp_parser_parameter_declaration (cp_parser *parser
 				&declares_class_or_enum);
 
   /* Complain about missing 'typename' or other invalid type names.  */
-  if (!decl_specifiers.any_type_specifiers_p)
-    cp_parser_parse_and_diagnose_invalid_type_name (parser);
+  if (!decl_specifiers.any_type_specifiers_p
+      && cp_parser_parse_and_diagnose_invalid_type_name (parser))
+    decl_specifiers.type = error_mark_node;
 
   /* If an error occurred, there's no reason to attempt to parse the
      rest of the declaration.  */
Index: testsuite/g++.dg/parse/error3.C
===================================================================
--- testsuite/g++.dg/parse/error3.C	(revision 199102)
+++ testsuite/g++.dg/parse/error3.C	(working copy)
@@ -5,5 +5,4 @@  static void InstantiateConstraint(const float&, un
                                   void(*AddFunction)(const TYPE&,bool&,
                                                      char*, char*,
                                                      unsigned*));
-// { dg-error "64: ISO C\\+\\+ forbids declaration of 'parameter' with no type" "forbids" { target *-*-* }  { 5 } }
 // { dg-error "60: 'TYPE' does not name a type" "does not" { target *-*-* } { 5 } }
Index: testsuite/g++.dg/parse/error36.C
===================================================================
--- testsuite/g++.dg/parse/error36.C	(revision 199102)
+++ testsuite/g++.dg/parse/error36.C	(working copy)
@@ -26,7 +26,6 @@  template <class T> struct B
 // PR c++/40738
 template <class T>
 void g(const A<T>::type &t);	// { dg-error "typename" "typename" }
-// { dg-error "no type" "no type" { target *-*-* } 28 }
 
 // PR c++/18451
 template <class T> A<T>::B A<T>::b; // { dg-error "typename" }
Index: testsuite/g++.dg/parse/error52.C
===================================================================
--- testsuite/g++.dg/parse/error52.C	(revision 0)
+++ testsuite/g++.dg/parse/error52.C	(working copy)
@@ -0,0 +1,11 @@ 
+// PR c++/12288
+
+class X {};
+
+struct S {
+  explicit S (const X::T&) {}  // { dg-error "does not name a type" }
+};
+
+class Y {};
+
+typedef Y::T xt;               // { dg-error "does not name a type" }