http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49353

           Summary: C++ frontend should not declare function EXTERN when
                    it forces them to stay
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: hubi...@gcc.gnu.org


Hi,
testsuite/g++.dg/opt/inline8.C shows problem where C++ frontend produce extern
inline function foo.
Now it wants to make it stay in program that happens via:
void
mark_needed (tree decl)
{
  /* It's possible that we no longer need to set
     TREE_SYMBOL_REFERENCED here directly, but doing so is
     harmless.  */
  TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)) = 1;
  mark_decl_referenced (decl);
}

Note that symbol referenced hack.  This match corresponding hack in
cgraphunit.c:
   /* ??? If the assembler name is set by hand, it is possible to assemble
      the name later after finalizing the function and the fact is noticed
      in assemble_name then.  This is arguably a bug.  */

   if (DECL_ASSEMBLER_NAME_SET_P (decl)
       && TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
     return true;

The declaration looks as:
 <function_decl 0x7ffff76d9200 operator new
    type <function_type 0x7ffff76d8540
        type <pointer_type 0x7ffff77a2f18 type <void_type 0x7ffff77a2e70 void>
            public unsigned DI
            size <integer_cst 0x7ffff77a6260 constant 64>
            unit size <integer_cst 0x7ffff77a6280 constant 8>
            align 64 symtab 0 alias set -1 canonical type 0x7ffff77a2f18
            pointer_to_this <pointer_type 0x7ffff77bc930>>
        QI
        size <integer_cst 0x7ffff77a6000 constant 8>
        unit size <integer_cst 0x7ffff77a6020 constant 1>
        align 8 symtab 0 alias set -1 canonical type 0x7ffff76d8498
        arg-types <tree_list 0x7ffff76c9898 value <integer_type 0x7ffff77a2690
long unsigned int>
            chain <tree_list 0x7ffff76c98c0 value <pointer_type 0x7ffff77a2f18>
                chain <tree_list 0x7ffff77938e8 value <void_type 0x7ffff77a2e70
void>>>>
        throws <tree_list 0x7ffff76c92f8>>
    nothrow public static external weak autoinline decl_5 QI defer-output file
a.C line 6 col 14 align 8 context <translation_unit_decl 0x7ffff7798958 D.1>
initial <block 0x7ffff76e8000>
    arguments <parm_decl 0x7ffff7795908 D.2065
        type <integer_type 0x7ffff77a2690 long unsigned int public unsigned DI
size <integer_cst 0x7ffff77a6260 64> unit size <integer_cst 0x7ffff77a6280 8>
            align 64 symtab 0 alias set -1 canonical type 0x7ffff77a2690
precision 64 min <integer_cst 0x7ffff77a62a0 0> max <integer_cst 0x7ffff77a6240
18446744073709551615>>
        unsigned DI file a.C line 6 col 27 size <integer_cst 0x7ffff77a6260 64>
unit size <integer_cst 0x7ffff77a6280 8>
        align 64 context <function_decl 0x7ffff76d9200 operator new>
        arg-type <integer_type 0x7ffff77a2690 long unsigned int>
        chain <parm_decl 0x7ffff7795990 p type <pointer_type 0x7ffff77a2f18>
            used unsigned DI file a.C line 6 col 48 size <integer_cst
0x7ffff77a6260 64> unit size <integer_cst 0x7ffff77a6280 8>
            align 64 context <function_decl 0x7ffff76d9200 operator new>
            arg-type <pointer_type 0x7ffff77a2f18>>>
    result <result_decl 0x7ffff7797300 D.2068 type <pointer_type
0x7ffff77a2f18>
        unsigned ignored DI file a.C line 6 col 57 size <integer_cst
0x7ffff77a6260 64> unit size <integer_cst 0x7ffff77a6280 8>
        align 64 context <function_decl 0x7ffff76d9200 operator new>>
    full-name "void* operator new(long unsigned int, void*) throw ()"
    not-really-extern pending-inline-info 0x7ffff778bcb0
    struct-function 0x7ffff76da1c8 chain <function_decl 0x7ffff76c7e00
__cxa_call_unexpected>>

I believe that the correct way to represnet this is to drop "EXTERN" flag in
those and similar cases where C++ FE currently use mark_decl_referenced.

How hard is to fix this?

Reply via email to