I believe this is valid C++:
extern "C++" struct S { static int x; } s;
g++ 4.2.4, 4.3.1, and the Debian version of 4.3.2 reject the declaration with
the error:
static.cpp:1: error: invalid use of ‘static’ in linkage specification
I don't think static members of structures were intended to be disallowed by
the prohibition duplicate storage classes in declarations like
extern "lang" static int x;
This seems to fix the problem:
===================================================================
--- gcc/gcc/cp/parser.c (revision 5135)
+++ gcc/gcc/cp/parser.c (revision 5136)
@@ -13423,6 +13423,7 @@
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;
@@ -13475,6 +13476,10 @@
/* 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)
@@ -13587,6 +13592,8 @@
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;
}
--
Summary: Invalid "invalid use of static" error
Product: gcc
Version: 4.3.2
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jfc at mit dot edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37877