+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-25 Richard Henderson <rth@redhat.com>
PR target/6788
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");
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);
}
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-fno-common" } */
+
+/* COFF does not support weak, and dg doesn't support UNSUPPORTED. */
+/* { dg-do compile { xfail *-*-coff i?86-pc-cygwin h8300-*-hms } } */
+
+/* { dg-final { global target_triplet } } */
+/* { 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\]_?f1" } } */
+/* { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]_?f2" } } */
+/* { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]_?f3" } } */
+/* { dg-final { scan-assembler "weak\[^ \t\]*\[ \t\]_?f4" } } */
+/* { dg-final { scan-assembler "notf1" } } */
+/* { dg-final { scan-assembler "notf2" } } */
+/* { dg-final { scan-assembler "notf3" } } */
+/* { dg-final { scan-assembler "notf4" } } */
+
+void f1() __attribute__((weak, alias("notf1")));
+void f2() __attribute__((alias("notf2"), weak));
+
+#pragma weak f3=notf3
+void f3();
+
+void f4();
+#pragma weak f4=notf4