]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[multiple changes]
authorRichard Henderson <rth@redhat.com>
Mon, 27 May 2002 05:48:20 +0000 (22:48 -0700)
committerRichard Henderson <rth@gcc.gnu.org>
Mon, 27 May 2002 05:48:20 +0000 (22:48 -0700)
2002-05-25  Richard Henderson  <rth@redhat.com>
* c-pragma.c (apply_pragma_weak): Convert value identifier to
string for decl_attributes.
(handle_pragma_weak): Call assemble_alias if we're modifying
an existing decl.

* gcc.dg/weak-9.c: New.

2002-05-15  Richard Henderson  <rth@redhat.com>
* varasm.c (merge_weak): Remove special case for extern and common.

2002-05-15  Richard Henderson  <rth@redhat.com>
* varasm.c (merge_weak): Error for any weakening after definition.
Adjust weakening after use warning to catch more cases.
(assemble_alias): Set TREE_USED and TREE_ASM_WRITTEN consistently.
* config/alpha/alpha.c (alpha_encode_section_info): Do not abort.

* gcc.dg/weak-5.c (vfoo1c): No warning here.
(vfoo1f): Warning here.
(vfoo1l): Don't redefine the alias.

2002-03-02  Richard Henderson  <rth@redhat.com>
* attribs.c (handle_alias_attribute): Don't call assemble_alias.
* toplev.c (rest_of_decl_compilation): Invoke assemble_alias when
needed.

From-SVN: r53910

gcc/ChangeLog
gcc/attribs.c
gcc/c-pragma.c
gcc/config/alpha/alpha.c
gcc/testsuite/gcc.dg/weak-5.c
gcc/toplev.c
gcc/varasm.c

index 89dc8cb13f033929f0aea10ed0a922fb906e63fd..54eb27630e2732173f230a236681e6f0b5c00c1e 100644 (file)
@@ -1,3 +1,25 @@
+2002-05-26  Richard Henderson  <rth@redhat.com>
+
+       2002-05-25  Richard Henderson  <rth@redhat.com>
+       * c-pragma.c (apply_pragma_weak): Convert value identifier to 
+       string for decl_attributes.
+       (handle_pragma_weak): Call assemble_alias if we're modifying
+       an existing decl.
+
+       2002-05-15  Richard Henderson  <rth@redhat.com>
+       * varasm.c (merge_weak): Remove special case for extern and common.
+
+       2002-05-15  Richard Henderson  <rth@redhat.com>
+       * varasm.c (merge_weak): Error for any weakening after definition.
+       Adjust weakening after use warning to catch more cases.
+       (assemble_alias): Set TREE_USED and TREE_ASM_WRITTEN consistently.
+       * config/alpha/alpha.c (alpha_encode_section_info): Do not abort.
+
+       2002-03-02  Richard Henderson  <rth@redhat.com>
+       * attribs.c (handle_alias_attribute): Don't call assemble_alias.
+       * toplev.c (rest_of_decl_compilation): Invoke assemble_alias when
+       needed.
+
 2002-05-26  Jakub Jelinek  <jakub@redhat.com>
 
        * cse.c (fold_rtx): Don't optimize if SUBREG changes mode class.
index b915c88071670bc09087ec6de6d11d0ecbd3b8d3..47b7cf21bf792f7d51ac0ea41daa633d676d2109 100644 (file)
@@ -1050,7 +1050,6 @@ handle_alias_attribute (node, name, args, flags, no_add_attrs)
        DECL_INITIAL (decl) = error_mark_node;
       else
        DECL_EXTERNAL (decl) = 0;
-      assemble_alias (decl, id);
     }
   else
     {
index d5df35595975e07d7b593e5f25710825c2f35c9d..a0a99fdd96402acb196100837125dc7a8e8c814b 100644 (file)
@@ -284,9 +284,14 @@ apply_pragma_weak (decl, value)
      tree decl, value;
 {
   if (value)
-    decl_attributes (&decl, build_tree_list (get_identifier ("alias"),
-                                            build_tree_list (NULL, value)),
-                    0);
+    {
+      value = build_string (IDENTIFIER_LENGTH (value),
+                           IDENTIFIER_POINTER (value));
+      decl_attributes (&decl, build_tree_list (get_identifier ("alias"),
+                                              build_tree_list (NULL, value)),
+                      0);
+    }
+
   if (SUPPORTS_WEAK && DECL_EXTERNAL (decl) && TREE_USED (decl)
       && TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
     warning_with_decl (decl, "applying #pragma weak `%s' after first use results in unspecified behavior");
@@ -343,7 +348,11 @@ handle_pragma_weak (dummy)
 
   decl = identifier_global_value (name);
   if (decl && TREE_CODE_CLASS (TREE_CODE (decl)) == 'd')
-    apply_pragma_weak (decl, value);
+    {
+      apply_pragma_weak (decl, value);
+      if (value)
+       assemble_alias (decl, value);
+    }
   else
     pending_weaks = tree_cons (name, value, pending_weaks);
 }
index c91e68cd4e201f3240f4413b1b4cce683024d1b1..3bc8e4ded81c055fe9587cbd1054d76bb7f0d7c3 100644 (file)
@@ -1664,7 +1664,11 @@ alpha_encode_section_info (decl)
       XSTR (XEXP (DECL_RTL (decl), 0), 0) = string;
     }
   else if (symbol_str[0] == '@')
-    abort ();
+    {
+      /* We're hosed.  This can happen when the user adds a weak
+        attribute after rtl generation.  They should have gotten
+        a warning about unspecified behaviour from varasm.c.  */
+    }
 }
 
 /* legitimate_address_p recognizes an RTL expression that is a valid
index a71c2a84e480d1c8025f56e23067a8660ee23449..e6755cc468089dc3acabff362c6b45b06ed5b332 100644 (file)
@@ -9,18 +9,18 @@
 /* { dg-final { if [string match h8300-*-hms $target_triplet ] {return} } } */
 /* { dg-final { if [string match i?86-pc-cygwin $target_triplet ] {return} } } */
 /* { dg-final { if [string match *-*-coff $target_triplet ] {return} } } */
-/* { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]vfoo1a" } } */
-/* { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]vfoo1b" } } */
-/* { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]vfoo1c" } } */
-/* { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]vfoo1d" } } */
-/* { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]vfoo1e" } } */
-/* { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]vfoo1f" } } */
-/* { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]vfoo1g" } } */
-/* { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]vfoo1h" } } */
-/* { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]vfoo1i" } } */
-/* { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]vfoo1j" } } */
-/* { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]vfoo1k" } } */
-/* { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]vfoo1l" } } */
+/* { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]_?vfoo1a" } } */
+/* { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]_?vfoo1b" } } */
+/* { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]_?vfoo1c" } } */
+/* { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]_?vfoo1d" } } */
+/* { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]_?vfoo1e" } } */
+/* { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]_?vfoo1f" } } */
+/* { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]_?vfoo1g" } } */
+/* { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]_?vfoo1h" } } */
+/* { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]_?vfoo1i" } } */
+/* { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]_?vfoo1j" } } */
+/* { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]_?vfoo1k" } } */
+/* { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]_?vfoo1l" } } */
 
 /* test variable addresses with __attribute__ ((weak)) */
 
@@ -45,7 +45,7 @@ void * foo1c (void)
 {
   return (void *)&vfoo1c;
 }
-extern int vfoo1c __attribute__((weak)); /* { dg-warning "weak declaration" "weak declaration" } */
+extern int vfoo1c __attribute__((weak)); /* { dg-warning "unspecified behavior" } */
 
 
 extern int vfoo1d __attribute__((weak));
@@ -69,7 +69,7 @@ void * foo1f (void)
 {
   return (void *)&vfoo1f;
 }
-extern int vfoo1f __attribute__((weak));
+extern int vfoo1f __attribute__((weak)); /* { dg-warning "unspecified behavior" } */
 
 
 extern int vfoo1g;
@@ -77,7 +77,7 @@ void * foo1g (void)
 {
   return (void *)&vfoo1g;
 }
-int vfoo1g __attribute__((weak));
+int vfoo1g __attribute__((weak)); /* { dg-warning "unspecified behavior" } */
 
 
 extern int vfoo1h __attribute__((weak));
@@ -112,6 +112,4 @@ int vfoo1k = 1;
 
 
 int vfoox1l = 1;
-extern int vfoo1l __attribute__((alias ("vfoox1l")));
 extern int vfoo1l __attribute__((weak, alias ("vfoox1l")));
-
index 8cb7ec1b15228f092b98fc105a2ea15f081cad37..efc7c973ac41aaae755da240ca9c287e0a4a1b39 100644 (file)
@@ -2248,6 +2248,19 @@ rest_of_decl_compilation (decl, asmspec, top_level, at_end)
 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END)
 #endif
 
+  /* We deferred calling assemble_alias so that we could collect
+     other attributes such as visibility.  Emit the alias now.  */
+  {
+    tree alias;
+    alias = lookup_attribute ("alias", DECL_ATTRIBUTES (decl));
+    if (alias)
+      {
+       alias = TREE_VALUE (TREE_VALUE (alias));
+       alias = get_identifier (TREE_STRING_POINTER (alias));
+        assemble_alias (decl, alias);
+      }
+  }
+
   /* Forward declarations for nested functions are not "external",
      but we need to treat them as if they were.  */
   if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
index 3f9fd213366fde2fd675448d07dcf851418091ae..6e55628611270f531fafc7cff3bb97e368f0f771 100644 (file)
@@ -5017,14 +5017,6 @@ merge_weak (newdecl, olddecl)
   if (DECL_WEAK (newdecl) == DECL_WEAK (olddecl))
     return;
 
-  if (SUPPORTS_WEAK
-      && DECL_WEAK (newdecl) 
-      && DECL_EXTERNAL (newdecl) && DECL_EXTERNAL (olddecl)
-      && (TREE_CODE (olddecl) != VAR_DECL || ! TREE_STATIC (olddecl))
-      && TREE_USED (olddecl)
-      && TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (olddecl)))
-    warning_with_decl (newdecl, "weak declaration of `%s' after first use results in unspecified behavior");
-
   if (DECL_WEAK (newdecl))
     {
       tree wd;
@@ -5035,10 +5027,17 @@ merge_weak (newdecl, olddecl)
         go back and make it weak.  This error cannot caught in
         declare_weak because the NEWDECL and OLDDECL was not yet
         been merged; therefore, TREE_ASM_WRITTEN was not set.  */
-      if (TREE_CODE (olddecl) == FUNCTION_DECL && TREE_ASM_WRITTEN (olddecl))
+      if (TREE_ASM_WRITTEN (olddecl))
        error_with_decl (newdecl, 
                         "weak declaration of `%s' must precede definition");
-      
+
+      /* If we've already generated rtl referencing OLDDECL, we may
+        have done so in a way that will not function properly with
+        a weak symbol.  */
+      else if (TREE_USED (olddecl)
+              && TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (olddecl)))
+       warning_with_decl (newdecl, "weak declaration of `%s' after first use results in unspecified behavior");
+
       if (SUPPORTS_WEAK)
        {
          /* We put the NEWDECL on the weak_decls list at some point.
@@ -5175,7 +5174,6 @@ assemble_alias (decl, target)
 #else
   ASM_OUTPUT_DEF (asm_out_file, name, IDENTIFIER_POINTER (target));
 #endif
-  TREE_ASM_WRITTEN (decl) = 1;
 #else /* !ASM_OUTPUT_DEF */
 #if defined (ASM_OUTPUT_WEAK_ALIAS) || defined (ASM_WEAKEN_DECL)
   if (! DECL_WEAK (decl))
@@ -5186,11 +5184,14 @@ assemble_alias (decl, target)
 #else
   ASM_OUTPUT_WEAK_ALIAS (asm_out_file, name, IDENTIFIER_POINTER (target));
 #endif
-  TREE_ASM_WRITTEN (decl) = 1;
 #else
   warning ("alias definitions not supported in this configuration; ignored");
 #endif
 #endif
+
+  TREE_USED (decl) = 1;
+  TREE_ASM_WRITTEN (decl) = 1;
+  TREE_ASM_WRITTEN (DECL_ASSEMBLER_NAME (decl)) = 1;
 }
 
 /* Returns 1 if the target configuration supports defining public symbols