From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28189 invoked by alias); 20 Oct 2008 13:29:23 -0000 Received: (qmail 27949 invoked by uid 48); 20 Oct 2008 13:27:59 -0000 Date: Mon, 20 Oct 2008 13:29:00 -0000 Subject: [Bug c++/37877] New: Invalid "invalid use of static" error X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "jfc at mit dot edu" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2008-10/txt/msg01291.txt.bz2 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