]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/9112 (new C++ parser rejects code older parsers accepted)
authorMark Mitchell <mark@codesourcery.com>
Tue, 31 Dec 2002 18:48:19 +0000 (18:48 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Tue, 31 Dec 2002 18:48:19 +0000 (18:48 +0000)
PR c++/9112
* parser.c (cp_parser_direct_declarator): Handle erroneous
parenthesized declarators correctly.

PR c++/9112
* g++.dg/parse/expr1.C: New test.

From-SVN: r60706

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/expr1.C [new file with mode: 0644]

index 8a5483350ed305feb4beede660db5099fc1e9297..49b4ca11162ac4f3fff9c50c430ac4ac2e33c085 100644 (file)
@@ -1,3 +1,9 @@
+2002-12-31  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/9112
+       * parser.c (cp_parser_direct_declarator): Handle erroneous
+       parenthesized declarators correctly.
+
 2002-12-31  Gabriel Dos Reis  <gdr@integrable-solutions.net>
 
        * cp-tree.h (pending_lang_change): Declare.
index 6c40d9db4748c1ad3fde584e921cb9035a47277b..13876e529ba255f6a142d6a404c8747a8c6b249a 100644 (file)
@@ -10023,6 +10023,8 @@ cp_parser_direct_declarator (parser, abstract_p, ctor_dtor_or_conv_p)
      declarator.  */
   if (token->type == CPP_OPEN_PAREN)
     {
+      bool error_p;
+
       /* For an abstract declarator we do not know whether we are
         looking at the beginning of a parameter-declaration-clause,
         or at a parenthesized abstract declarator.  For example, if
@@ -10041,7 +10043,7 @@ cp_parser_direct_declarator (parser, abstract_p, ctor_dtor_or_conv_p)
       declarator 
        = cp_parser_declarator (parser, abstract_p, ctor_dtor_or_conv_p);
       /* Expect a `)'.  */
-      cp_parser_require (parser, CPP_CLOSE_PAREN, "`)'");
+      error_p = !cp_parser_require (parser, CPP_CLOSE_PAREN, "`)'");
 
       /* If parsing a parenthesized abstract declarator didn't work,
         try a parameter-declaration-clause.  */
@@ -10050,7 +10052,8 @@ cp_parser_direct_declarator (parser, abstract_p, ctor_dtor_or_conv_p)
       /* If we were not parsing an abstract declarator, but failed to
         find a satisfactory nested declarator, then an error has
         occurred.  */
-      else if (!abstract_p && declarator == error_mark_node)
+      else if (!abstract_p 
+              && (declarator == error_mark_node || error_p))
        return error_mark_node;
       /* Default args cannot appear in an abstract decl.  */
       parser->default_arg_ok_p = false;
index b82d4f3eb2d149caf59d7410533443f9dbb3001f..7fc0cd9444bec1da2ef31111220cacb507e870fb 100644 (file)
@@ -1,3 +1,8 @@
+2002-12-31  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/9112
+       * g++.dg/parse/expr1.C: New test.
+
 2002-12-30  Daniel Jacobowitz  <drow@mvista.com>
 
        * gcc.c-torture/compile/20021230-1.c: New test.
diff --git a/gcc/testsuite/g++.dg/parse/expr1.C b/gcc/testsuite/g++.dg/parse/expr1.C
new file mode 100644 (file)
index 0000000..2ef8218
--- /dev/null
@@ -0,0 +1,8 @@
+struct A {
+  A (int, int);
+  void f ();
+};
+
+void f (int a) {
+  A (a, a).f ();
+}