]> gcc.gnu.org Git - gcc.git/commitdiff
decl.c (warn_extern_redeclared_static): Don't get confused by static member functions.
authorMark Mitchell <mark@codesourcery.com>
Fri, 17 Sep 1999 18:15:21 +0000 (18:15 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Fri, 17 Sep 1999 18:15:21 +0000 (18:15 +0000)
* decl.c (warn_extern_redeclared_static): Don't get confused by
static member functions.
(duplicate_decls): Merge DECL_THIS_STATIC.

* decl.c (expand_static_init): Make sure assignments to local
statics actually occur.

From-SVN: r29477

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/g++.old-deja/g++.other/linkage5.C [new file with mode: 0644]
gcc/testsuite/g++.old-deja/g++.other/static7.C [new file with mode: 0644]

index 88b123c0417e2c1adf6b510cd9d6b2d28c80bbe8..ae81e8a4e47b22419d0e903bdaf5bf2b32935bae 100644 (file)
@@ -1,3 +1,12 @@
+1999-09-17  Mark Mitchell  <mark@codesourcery.com>
+
+       * decl.c (warn_extern_redeclared_static): Don't get confused by
+       static member functions.
+       (duplicate_decls): Merge DECL_THIS_STATIC.
+
+       * decl.c (expand_static_init): Make sure assignments to local
+       statics actually occur.
+
 1999-09-17  Nathan Sidwell  <nathan@acm.org>
 
        * call.c (perform_implicit_conversion): Deal with error_mark_node.
index 7047f342211e62dc39c80a34bffb70ef8f46457f..d2e41d596ef9a74c8bc9a21f950eb59136223721 100644 (file)
@@ -2939,6 +2939,12 @@ warn_extern_redeclared_static (newdecl, olddecl)
 
   if (TREE_CODE (newdecl) == TYPE_DECL)
     return;
+  
+  /* Don't get confused by static member functions; that's a different
+     use of `static'.  */
+  if (TREE_CODE (newdecl) == FUNCTION_DECL
+      && DECL_STATIC_FUNCTION_P (newdecl))
+    return;
 
   /* If the old declaration was `static', or the new one isn't, then
      then everything is OK.  */
@@ -3284,6 +3290,7 @@ duplicate_decls (newdecl, olddecl)
       DECL_ABSTRACT_VIRTUAL_P (newdecl) |= DECL_ABSTRACT_VIRTUAL_P (olddecl);
       DECL_VIRTUAL_P (newdecl) |= DECL_VIRTUAL_P (olddecl);
       DECL_NEEDS_FINAL_OVERRIDER_P (newdecl) |= DECL_NEEDS_FINAL_OVERRIDER_P (olddecl);
+      DECL_THIS_STATIC (newdecl) |= DECL_THIS_STATIC (olddecl);
       new_defines_function = DECL_INITIAL (newdecl) != NULL_TREE;
       
       /* Optionally warn about more than one declaration for the same
@@ -7987,9 +7994,12 @@ expand_static_init (decl, init)
          || (init && TREE_CODE (init) == TREE_LIST))
        assignment = build_aggr_init (decl, init, 0);
       else if (init)
-       /* The initialization we're doing here is just a bitwise
-          copy.  */
-       assignment = build (INIT_EXPR, TREE_TYPE (decl), decl, init);
+       {
+         /* The initialization we're doing here is just a bitwise
+            copy.  */
+         assignment = build (INIT_EXPR, TREE_TYPE (decl), decl, init);
+         TREE_SIDE_EFFECTS (assignment) = 1;
+       }
       else
        assignment = NULL_TREE;
 
diff --git a/gcc/testsuite/g++.old-deja/g++.other/linkage5.C b/gcc/testsuite/g++.old-deja/g++.other/linkage5.C
new file mode 100644 (file)
index 0000000..4bbcf23
--- /dev/null
@@ -0,0 +1,6 @@
+// Build don't link:
+// Origin: Jason Merrill <jason@cygnus.com>
+
+static int f ();
+int f ();
+static int f ();
diff --git a/gcc/testsuite/g++.old-deja/g++.other/static7.C b/gcc/testsuite/g++.old-deja/g++.other/static7.C
new file mode 100644 (file)
index 0000000..d710e4f
--- /dev/null
@@ -0,0 +1,9 @@
+// Origin: Jason Merrill <jason@cygnus.com>
+
+int j = 42;
+
+int main ()
+{
+  static int i = j;
+  return (i != 42);
+}
This page took 0.098927 seconds and 5 git commands to generate.