C++ name mangling not tracking extern "C"-ness of function types?

Stephan Bergmann sbergman@redhat.com
Thu Jun 26 08:21:00 GMT 2014


Quoting gcc/cp/mangle.c@34394:

> /* Non-terminal <function-type>.  NODE is a FUNCTION_TYPE or
>    METHOD_TYPE.  If INCLUDE_RETURN_TYPE is non-zero, the return type
>    is mangled before the parameter types.
>
>      <function-type> ::= F [Y] <bare-function-type> E   */
>
> static void
> write_function_type (type, include_return_type)
>      tree type;
>      int include_return_type;
> {
>   MANGLE_TRACE_TREE ("function-type", type);
>
>   write_char ('F');
>   /* We don't track whether or not a type is `extern "C"'.  Note that
>      you can have an `extern "C"' function that does not have
>      `extern "C"' type, and vice versa:
>
>        extern "C" typedef void function_t();
>        function_t f; // f has C++ linkage, but its type is
>                      // `extern "C"'
>
>        typedef void function_t();
>        extern "C" function_t f; // Vice versa.
>
>      See [dcl.link].  */
>   write_bare_function_type (type, include_return_type);
>   write_char ('E');
> }

Is there any rationale for not tracking extern "C"-ness here (beyond: 
"its just simpler that way")?  I do understand that technically it 
doesn't make much of a difference whether a function's type is extern 
"C" or not, but it took me by surprise to find this deliberate deviation 
from the Itanium ABI.

Stephan



More information about the Gcc mailing list