public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/37877]  New: Invalid "invalid use of static" error
@ 2008-10-20 13:29 jfc at mit dot edu
  2008-12-24 14:19 ` [Bug c++/37877] [4.3/4.4 Regression] " pinskia at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: jfc at mit dot edu @ 2008-10-20 13:29 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1923 bytes --]

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


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2009-07-10 16:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-20 13:29 [Bug c++/37877] New: Invalid "invalid use of static" error jfc at mit dot edu
2008-12-24 14:19 ` [Bug c++/37877] [4.3/4.4 Regression] " pinskia at gcc dot gnu dot org
2008-12-29 21:29 ` rguenth at gcc dot gnu dot org
2008-12-30 11:08 ` jakub at gcc dot gnu dot org
2009-01-09 14:46 ` jakub at gcc dot gnu dot org
2009-01-09 14:47 ` [Bug c++/37877] [4.3 " jakub at gcc dot gnu dot org
2009-01-24 10:27 ` rguenth at gcc dot gnu dot org
2009-07-10 15:57 ` rguenth at gcc dot gnu dot org
2009-07-10 16:04 ` rguenth at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).