@@ -314,7 +314,7 @@ class DeclVisitor : public Visitor
314314 DECL_INITIAL (d->sinit ) = layout_struct_initializer (d);
315315
316316 if (d->isInstantiated ())
317- d_comdat_linkage (d->sinit );
317+ d_linkonce_linkage (d->sinit );
318318
319319 d_finish_decl (d->sinit );
320320
@@ -420,13 +420,13 @@ class DeclVisitor : public Visitor
420420
421421 /* Generate static initialiser. */
422422 DECL_INITIAL (d->sinit ) = layout_class_initializer (d);
423- d_comdat_linkage (d->sinit );
423+ d_linkonce_linkage (d->sinit );
424424 d_finish_decl (d->sinit );
425425
426426 /* Put out the TypeInfo. */
427427 create_typeinfo (d->type , NULL );
428428 DECL_INITIAL (d->csym ) = layout_classinfo (d);
429- d_comdat_linkage (d->csym );
429+ d_linkonce_linkage (d->csym );
430430 d_finish_decl (d->csym );
431431
432432 /* Put out the vtbl[]. */
@@ -487,7 +487,7 @@ class DeclVisitor : public Visitor
487487 d->type ->vtinfo ->accept (this );
488488
489489 DECL_INITIAL (d->csym ) = layout_classinfo (d);
490- d_comdat_linkage (d->csym );
490+ d_linkonce_linkage (d->csym );
491491 d_finish_decl (d->csym );
492492
493493 /* Add this decl to the current binding level. */
@@ -524,7 +524,7 @@ class DeclVisitor : public Visitor
524524 DECL_INITIAL (d->sinit ) = build_expr (tc->sym ->defaultval , true );
525525
526526 if (d->isInstantiated ())
527- d_comdat_linkage (d->sinit );
527+ d_linkonce_linkage (d->sinit );
528528
529529 d_finish_decl (d->sinit );
530530
@@ -1152,6 +1152,7 @@ get_symbol_decl (Declaration *decl)
11521152 {
11531153 TREE_PUBLIC (decl->csym ) = 1 ;
11541154 DECL_ARTIFICIAL (decl->csym ) = 1 ;
1155+ DECL_DECLARED_INLINE_P (decl->csym ) = 1 ;
11551156 d_comdat_linkage (decl->csym );
11561157 }
11571158
@@ -1229,13 +1230,7 @@ get_symbol_decl (Declaration *decl)
12291230 else
12301231 DECL_EXTERNAL (decl->csym ) = 1 ;
12311232
1232- d_comdat_linkage (decl->csym );
1233-
1234- /* Normally the backend only emits COMDAT things when they are needed.
1235- If this decl is meant to be externally visible, then make sure that
1236- to mark it so that it is indeed needed. */
1237- if (TREE_PUBLIC (decl->csym ))
1238- mark_needed (decl->csym );
1233+ d_linkonce_linkage (decl->csym );
12391234 }
12401235 else
12411236 {
@@ -1300,9 +1295,6 @@ declare_extern_var (tree ident, tree type)
13001295 TREE_STATIC (decl) = 1 ;
13011296 TREE_PUBLIC (decl) = 1 ;
13021297
1303- /* Mark it needed so we don't forget to emit it. */
1304- mark_needed (decl);
1305-
13061298 /* The decl has not been defined -- yet. */
13071299 DECL_EXTERNAL (decl) = 1 ;
13081300
@@ -1476,6 +1468,12 @@ d_finish_decl (tree decl)
14761468 }
14771469 }
14781470
1471+ /* Without weak symbols, symbol should be put in .common, but that can't
1472+ be done if there is a non-zero initializer. */
1473+ if (DECL_COMDAT (decl) && DECL_COMMON (decl)
1474+ && initializer_zerop (DECL_INITIAL (decl)))
1475+ DECL_INITIAL (decl) = error_mark_node;
1476+
14791477 /* Add this decl to the current binding level. */
14801478 d_pushdecl (decl);
14811479
@@ -1615,8 +1613,6 @@ finish_thunk (tree thunk, tree function)
16151613
16161614 if (!stdarg_p (TREE_TYPE (thunk)))
16171615 {
1618- /* Put generic thunk into COMDAT. */
1619- d_comdat_linkage (thunk);
16201616 thunk_node->create_edge (funcn, NULL , thunk_node->count );
16211617 thunk_node->expand_thunk (false , true );
16221618 }
@@ -2159,14 +2155,6 @@ d_comdat_group (tree decl)
21592155void
21602156d_comdat_linkage (tree decl)
21612157{
2162- /* COMDAT definitions have to be public. */
2163- if (!TREE_PUBLIC (decl))
2164- return ;
2165-
2166- /* Necessary to allow DECL_ONE_ONLY or DECL_WEAK functions to be inlined. */
2167- if (TREE_CODE (decl) == FUNCTION_DECL)
2168- DECL_DECLARED_INLINE_P (decl) = 1 ;
2169-
21702158 if (flag_weak)
21712159 make_decl_one_only (decl, d_comdat_group (decl));
21722160 else if (TREE_CODE (decl) == FUNCTION_DECL
0 commit comments