This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RFC: Stricter semantics for renaming pragmas


We currently have three ways of changing the object-file name of a
variable or function.  They are __asm__("foo") tacked on the end of
the declaration; #pragma redefine_extname; #pragma extern_prefix.  All
three of these are implemented in maybe_apply_renaming_pragma(); the
semantics are messy, particularly the semantics of what happens if
more than one applies to the same decl.  The implementation is also
inefficient, especially in that it forces the reification of
DECL_ASSEMBLER_NAME.  (I experimentally disabled m_a_r_p and compiled
a simple (but iostream-using) C++ test program; there were 654 fewer
calls to mangle_decl.)

I would like to know if the following revised semantics are
acceptable.  Implementing them will allow me to avoid ever
reifying DECL_ASSEMBLER_NAME from maybe_apply_renaming_pragma, unless
we are actually going to change what it is.

1) If any of the three ways of changing DECL_ASSEMBLER_NAME is applied
   to a decl whose DECL_ASSEMBLER_NAME is already set, a warning
   issues and the name does not change.  (The warning does not issue
   if it's a redundant operation - only if it's inconsistent.)

2) If #pragma extern_prefix is in effect and a declaration occurs with
   an __asm__ name, __asm__ wins.  No warning issues.

3) If #pragma extern_prefix is in effect, all pending #pragma
   redefine_extname operations are ignored; a warning does issue.

4) The "source name" for #pragma redefine_extname is the DECL_NAME,
   *not* the DECL_ASSEMBLER_NAME.  (Current code is inconsistent -
   it's the DECL_NAME if the #pragma occurs after the declaration, the
   DECL_ASSEMBLER_NAME if the #pragma occurs before the declaration.

5) In C++:

5a) Applying __asm__("name") to a declaration silently makes it extern "C".

5b) #pragma redefine_extname is ignored, with a warning, if applied to
    a declaration which is not extern "C".

5c) #pragma extern_prefix silently applies only to declarations which
    are extern "C".

Thoughts?

zw


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]