[C++ PATCH] Disable in_unbraced_linkage_specification_p while parsing class specifier (PR c++/37877)

Jakub Jelinek jakub@redhat.com
Fri Jan 9 13:32:00 GMT 2009


Hi!

This patch has been just posted in bugzilla by the submitter, but
looks correct to me.
I've bootstrapped/regtested it on {x86_64,i686}-linux.  Ok for trunk?

2009-01-09  John F. Carr  <jfc@mit.edu>

	PR c++/37877
	* parser.c (cp_parser_class_specifier): Clear
	parser->in_unbraced_linkage_specification_p while parsing class
	specifiers.

	* g++.dg/parse/linkage3.C: New test.

--- gcc/cp/parser.c.jj	2009-01-07 16:20:08.000000000 +0100
+++ gcc/cp/parser.c	2009-01-09 10:19:32.000000000 +0100
@@ -14879,6 +14879,7 @@ cp_parser_class_specifier (cp_parser* pa
   bool nested_name_specifier_p;
   unsigned saved_num_template_parameter_lists;
   bool saved_in_function_body;
+  bool saved_in_unbraced_linkage_specification_p;
   tree old_scope = NULL_TREE;
   tree scope = NULL_TREE;
   tree bases;
@@ -14930,6 +14931,10 @@ cp_parser_class_specifier (cp_parser* pa
   /* We are not in a function body.  */
   saved_in_function_body = parser->in_function_body;
   parser->in_function_body = false;
+  /* We are not immediately inside an extern "lang" block.  */
+  saved_in_unbraced_linkage_specification_p
+    = parser->in_unbraced_linkage_specification_p;
+  parser->in_unbraced_linkage_specification_p = false;
 
   /* Start the class.  */
   if (nested_name_specifier_p)
@@ -15042,6 +15047,8 @@ cp_parser_class_specifier (cp_parser* pa
   parser->in_function_body = saved_in_function_body;
   parser->num_template_parameter_lists
     = saved_num_template_parameter_lists;
+  parser->in_unbraced_linkage_specification_p
+    = saved_in_unbraced_linkage_specification_p;
 
   return type;
 }
--- gcc/testsuite/g++.dg/parse/linkage3.C.jj	2009-01-09 10:22:08.000000000 +0100
+++ gcc/testsuite/g++.dg/parse/linkage3.C	2009-01-09 10:20:46.000000000 +0100
@@ -0,0 +1,7 @@
+// PR c++/37877
+// { dg-do compile }
+
+extern "C++" struct S
+{
+  static int x;
+} s;

	Jakub



More information about the Gcc-patches mailing list