From 73f971b716256c5c37753748fa7c8ade3c49da21 Mon Sep 17 00:00:00 2001 From: "John F. Carr" Date: Fri, 9 Jan 2009 14:45:44 +0000 Subject: [PATCH] re PR c++/37877 (Invalid "invalid use of static" error) 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. From-SVN: r143206 --- gcc/cp/ChangeLog | 7 +++++++ gcc/cp/parser.c | 7 +++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/parse/linkage3.C | 7 +++++++ 4 files changed, 26 insertions(+) create mode 100644 gcc/testsuite/g++.dg/parse/linkage3.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a0be740d5dc..6d09fafb198 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2009-01-09 John F. Carr + + PR c++/37877 + * parser.c (cp_parser_class_specifier): Clear + parser->in_unbraced_linkage_specification_p while parsing class + specifiers. + 2009-01-07 Jakub Jelinek PR c++/38725 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 545d3ddb387..f497d664783 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -14873,6 +14873,7 @@ cp_parser_class_specifier (cp_parser* parser) 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; @@ -14924,6 +14925,10 @@ cp_parser_class_specifier (cp_parser* parser) /* 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) @@ -15036,6 +15041,8 @@ cp_parser_class_specifier (cp_parser* parser) 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; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 199cd6e10b9..a86c18caac4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-01-09 John F. Carr + + PR c++/37877 + * g++.dg/parse/linkage3.C: New test. + 2009-01-09 Jakub Jelinek PR middle-end/38771 diff --git a/gcc/testsuite/g++.dg/parse/linkage3.C b/gcc/testsuite/g++.dg/parse/linkage3.C new file mode 100644 index 00000000000..0d952d1e642 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/linkage3.C @@ -0,0 +1,7 @@ +// PR c++/37877 +// { dg-do compile } + +extern "C++" struct S +{ + static int x; +} s; -- 2.30.2