PR c++/27884
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 16 Jun 2006 18:45:50 +0000 (18:45 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 16 Jun 2006 18:45:50 +0000 (18:45 +0000)
* decl.c (have_extern_spec): Remove.
(start_decl): Do not check have_extern_spec.
(start_function): Likewise.
* cp-tree.h (have_extern_spec): Remove.
* parser.c (cp_parser_linkage_specification): Don't set
have_extern_spec.
(cp_parser_init_declarator): Likewise.
(cp_parser_parameter_declaration): Do not treat parameters as
within the scope of an unbraced linkage specification.
PR c++/27884
* g++.dg/parse/linkage2.C: New test

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@114727 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/linkage2.C [new file with mode: 0644]

index bb1ea7f..28e1709 100644 (file)
@@ -1,3 +1,16 @@
+2006-06-16  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/27884
+       * decl.c (have_extern_spec): Remove.
+       (start_decl): Do not check have_extern_spec.
+       (start_function): Likewise.
+       * cp-tree.h (have_extern_spec): Remove.
+       * parser.c (cp_parser_linkage_specification): Don't set
+       have_extern_spec.
+       (cp_parser_init_declarator): Likewise.
+       (cp_parser_parameter_declaration): Do not treat parameters as
+       within the scope of an unbraced linkage specification.
+
 2006-06-15  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/27689
index e9f28a6..4e4d8ec 100644 (file)
@@ -3943,8 +3943,6 @@ extern void initialize_artificial_var             (tree, tree);
 extern tree check_var_type                     (tree, tree);
 extern tree reshape_init (tree, tree);
 
-extern bool have_extern_spec;
-
 /* in decl2.c */
 extern bool check_java_method                  (tree);
 extern tree build_memfn_type                   (tree, tree, cp_cv_quals);
index 2d92fe3..7db989d 100644 (file)
@@ -240,10 +240,6 @@ enum deprecated_states {
 
 static enum deprecated_states deprecated_state = DEPRECATED_NORMAL;
 
-/* True if a declaration with an `extern' linkage specifier is being
-   processed.  */
-bool have_extern_spec;
-
 \f
 /* A TREE_LIST of VAR_DECLs.  The TREE_PURPOSE is a RECORD_TYPE or
    UNION_TYPE; the TREE_VALUE is a VAR_DECL with that type.  At the
@@ -3814,13 +3810,6 @@ start_decl (const cp_declarator *declarator,
 
   *pushed_scope_p = NULL_TREE;
 
-  /* This should only be done once on the top most decl.  */
-  if (have_extern_spec)
-    {
-      declspecs->storage_class = sc_extern;
-      have_extern_spec = false;
-    }
-
   /* An object declared as __attribute__((deprecated)) suppresses
      warnings of uses of other deprecated items.  */
   if (lookup_attribute ("deprecated", attributes))
@@ -10632,13 +10621,6 @@ start_function (cp_decl_specifier_seq *declspecs,
 {
   tree decl1;
 
-  if (have_extern_spec)
-    {
-      declspecs->storage_class = sc_extern;
-      /* This should only be done once on the outermost decl.  */
-      have_extern_spec = false;
-    }
-
   decl1 = grokdeclarator (declarator, declspecs, FUNCDEF, 1, &attrs);
   /* If the declarator is not suitable for a function definition,
      cause a syntax error.  */
index df175fa..964ab0e 100644 (file)
@@ -7732,9 +7732,7 @@ cp_parser_linkage_specification (cp_parser* parser)
       saved_in_unbraced_linkage_specification_p
        = parser->in_unbraced_linkage_specification_p;
       parser->in_unbraced_linkage_specification_p = true;
-      have_extern_spec = true;
       cp_parser_declaration (parser);
-      have_extern_spec = false;
       parser->in_unbraced_linkage_specification_p
        = saved_in_unbraced_linkage_specification_p;
     }
@@ -11063,10 +11061,7 @@ cp_parser_init_declarator (cp_parser* parser,
   if (!member_p)
     {
       if (parser->in_unbraced_linkage_specification_p)
-       {
-         decl_specifiers->storage_class = sc_extern;
-         have_extern_spec = false;
-       }
+       decl_specifiers->storage_class = sc_extern;
       decl = start_decl (declarator, decl_specifiers,
                         is_initialized, attributes, prefix_attributes,
                         &pushed_scope);
@@ -12119,9 +12114,16 @@ cp_parser_parameter_declaration_list (cp_parser* parser, bool *is_error)
 {
   cp_parameter_declarator *parameters = NULL;
   cp_parameter_declarator **tail = &parameters;
+  bool saved_in_unbraced_linkage_specification_p;
 
   /* Assume all will go well.  */
   *is_error = false;
+  /* The special considerations that apply to a function within an
+     unbraced linkage specifications do not apply to the parameters
+     to the function.  */
+  saved_in_unbraced_linkage_specification_p 
+    = parser->in_unbraced_linkage_specification_p;
+  parser->in_unbraced_linkage_specification_p = false;
 
   /* Look for more parameters.  */
   while (true)
@@ -12200,6 +12202,9 @@ cp_parser_parameter_declaration_list (cp_parser* parser, bool *is_error)
        }
     }
 
+  parser->in_unbraced_linkage_specification_p
+    = saved_in_unbraced_linkage_specification_p;
+
   return parameters;
 }
 
index f4a6ed4..a1eba47 100644 (file)
@@ -1,3 +1,8 @@
+2006-06-16  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/27884
+       * g++.dg/parse/linkage2.C: New test
+
 2006-06-16  Richard Guenther  <rguenther@suse.de>
 
        PR middle-end/27116
diff --git a/gcc/testsuite/g++.dg/parse/linkage2.C b/gcc/testsuite/g++.dg/parse/linkage2.C
new file mode 100644 (file)
index 0000000..aa204df
--- /dev/null
@@ -0,0 +1,3 @@
+// PR c++/27884
+
+extern "C" void foo(register int *my_perl);