diff mbox

[C++] Fix PR52841

Message ID Pine.LNX.4.64.1206041151130.5860@jbgna.fhfr.qr
State New
Headers show

Commit Message

Richard Biener June 4, 2012, 9:52 a.m. UTC
We are using the following patch from Fabien in our tree to fix
a rejects-valid bug quite appearant in our own codebase.

Re-bootstrap and regtest on the branch head currently running,
ok if that succeeds?

Thanks,
Richard.

2012-06-04  Fabien Chêne  <fabien@gcc.gnu.org>

	PR c++/52841
	* parser.c (cp_parser_alias_declaration): Return earlier
	if an error occured.

	* g++.dg/cpp0x/pr52841.C: New testcase.

Comments

Jason Merrill June 5, 2012, 6:13 p.m. UTC | #1
OK.

Jason
Fabien Chêne June 6, 2012, 8:09 a.m. UTC | #2
2012/6/5 Jason Merrill <jason@redhat.com>:
> OK.

Out of curiosity, do you happen to know what kind of problem was
triggered here ?
Shouldn't we fix the underlying issue as well ? Unless that the
canonical way to solve it be to simply return earlier...

Thanks,
Jason Merrill June 6, 2012, 4:17 p.m. UTC | #3
On 06/06/2012 04:09 AM, Fabien Chêne wrote:
> Out of curiosity, do you happen to know what kind of problem was
> triggered here ?
> Shouldn't we fix the underlying issue as well ? Unless that the
> canonical way to solve it be to simply return earlier...

Often if we continue parsing something on the assumption that the 
previous bits are correct it leads to problems; that's all there is to 
this bug.  When we see

   using sat::Solvable::bool_type;

cp_parser_alias_declaration eats "sat" and then tries to parse 
::Solvable::bool_type as a type-id, which fails.

Returning when we hit a parse error is the right fix.

Jason
Fabien Chêne June 7, 2012, 5:39 a.m. UTC | #4
2012/6/6 Jason Merrill <jason@redhat.com>:
[...]
> Often if we continue parsing something on the assumption that the previous
> bits are correct it leads to problems; that's all there is to this bug.
>  When we see
>
>  using sat::Solvable::bool_type;
>
> cp_parser_alias_declaration eats "sat" and then tries to parse
> ::Solvable::bool_type as a type-id, which fails.
>
> Returning when we hit a parse error is the right fix.

Thank you for the explanation.
diff mbox

Patch

Index: gcc/cp/parser.c
===================================================================
--- gcc/cp/parser.c	(revision 186200)
+++ gcc/cp/parser.c	(working copy)
@@ -15072,6 +15072,9 @@  cp_parser_alias_declaration (cp_parser*
 
   cp_parser_require (parser, CPP_EQ, RT_EQ);
 
+  if (cp_parser_error_occurred (parser))
+    return error_mark_node;
+
   /* Now we are going to parse the type-id of the declaration.  */
 
   /*
Index: gcc/testsuite/g++.dg/cpp0x/pr52841.C
===================================================================
--- gcc/testsuite/g++.dg/cpp0x/pr52841.C	(revision 0)
+++ gcc/testsuite/g++.dg/cpp0x/pr52841.C	(revision 0)
@@ -0,0 +1,17 @@ 
+// { dg-do compile }
+
+struct Solvable;
+namespace sat
+{
+  class Solvable
+    {
+  public:
+      typedef bool bool_type;
+    };
+}
+
+class Resolvable : public sat::Solvable
+{
+public:
+  using sat::Solvable::bool_type;
+};