[Bug c++/35606] New: Unresolved #pragma weak prevents all function aliasing in C++
ian at airs dot com
gcc-bugzilla@gcc.gnu.org
Sun Mar 16 08:26:00 GMT 2008
Compiling this simple C++ file:
#pragma weak my_weak_function
extern "C" void my_function_to_be_renamed (void) asm ("my_renamed_function");
gives me the warning
foo.cc:2: warning: asm declaration ignored due to conflict with previous rename
This does not make sense, as there is no previous rename. Worse, the warning
is telling the truth: the asm declaration really is ignored, and the function
is not renamed as it should be.
What is happening is that start_decl calls maybe_apply_pragma_weak before it
sees the rename. Since there is a pending unresolved weak declaration,
maybe_apply_pragma_weak calls decl_assembler_name on the newly created decl.
This has the effect of assigning the name to the decl.
When the C++ frontend gets around to applying the rename from the asm, it sees
that the assembler name has already been assigned. Hence the warning, and
hence the rename is ignored.
This does not happen with the C frontend because the C frontend calls
maybe_apply_pragma_weak from finish_decl, after the asm rename has been
applied. Perhaps a similar patch would work for the C++ frontend. I haven't
tried it.
--
Summary: Unresolved #pragma weak prevents all function aliasing
in C++
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ian at airs dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35606
More information about the Gcc-bugs
mailing list