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.carl...@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.carl...@oracle.com>

        PR c++/12288
        * g++.dg/parse/error52.C: New.
        * g++.dg/parse/error3.C: Adjust.
        * g++.dg/parse/error36.C: Likewise.
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" }

Reply via email to