This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH: PR 29408


This patch fixes PR c++/29408, a rejects-valid regression for a use of
a destructor raising from my recent patch to improve handling of
access declarations.  When what we're parsing is clearly not an access
declaration, we can just stop.  That should be just an optimization,
but a latent oddity in our handling of parsing template argument lists
makes this also a correctness fix -- and I judged fixing the
underlying oddity to be more risky.  

Tested on x86_64-unknown-linux-gnu, applied on the mainline.  I will
apply to the 4.1 branch when testing completes.

--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713

2006-10-16  Mark Mitchell  <mark@codesourcery.com>

	PR c++/29408
	* parser.c (cp_parser_using_declaration): Stop parsing when
	something goes wrong with an access declaration.

2006-10-16  Mark Mitchell  <mark@codesourcery.com>

	PR c++/29408
	* g++.dg/parse/dtor12.C: New test.

Index: gcc/cp/parser.c
===================================================================
--- gcc/cp/parser.c	(revision 117789)
+++ gcc/cp/parser.c	(working copy)
@@ -10681,6 +10681,12 @@ cp_parser_using_declaration (cp_parser* 
   if (!qscope)
     qscope = global_namespace;
 
+  if (access_declaration_p && cp_parser_error_occurred (parser))
+    /* Something has already gone wrong; there's no need to parse
+       further.  Since an error has occurred, the return value of
+       cp_parser_parse_definitely will be false, as required.  */
+    return cp_parser_parse_definitely (parser);
+
   /* Parse the unqualified-id.  */
   identifier = cp_parser_unqualified_id (parser,
 					 /*template_keyword_p=*/false,
Index: gcc/testsuite/g++.dg/parse/dtor12.C
===================================================================
--- gcc/testsuite/g++.dg/parse/dtor12.C	(revision 0)
+++ gcc/testsuite/g++.dg/parse/dtor12.C	(revision 0)
@@ -0,0 +1,6 @@
+// PR c++/29408
+
+template <class T> class a
+{
+  ~a<T>();
+};


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]