c-pragma.c (apply_pragma_weak): Convert value identifier to string for decl_attributes.

* 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.

From-SVN: r53884
This commit is contained in:
Richard Henderson 2002-05-25 20:38:37 -07:00 committed by Richard Henderson
parent 94fdf99db0
commit b53bb376d9
3 changed files with 48 additions and 4 deletions

View File

@ -1,3 +1,10 @@
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

View File

@ -283,9 +283,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");
@ -342,7 +347,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);
}

View File

@ -0,0 +1,28 @@
/* { 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