From: jason Date: Wed, 25 Feb 2015 21:46:29 +0000 (+0000) Subject: PR c++/65209 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bc3900eeeff1f1d5c37be4043e0be87d9ce45e1b;p=thirdparty%2Fgcc.git PR c++/65209 * decl2.c (constrain_visibility) [VISIBILITY_ANON]: Clear DECL_COMDAT. (constrain_visibility_for_template): Handle reference arguments. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@220991 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index fbebe8e324c3..ebe84c6dc693 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 2015-02-25 Jason Merrill + PR c++/65209 + * decl2.c (constrain_visibility) [VISIBILITY_ANON]: Clear + DECL_COMDAT. + (constrain_visibility_for_template): Handle reference arguments. + PR debug/58315 * decl.c (start_preparsed_function): Use create_artificial_label for cdtor_label. diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index a7bc08f6e56f..a4a5ebf58ea1 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -2175,6 +2175,7 @@ constrain_visibility (tree decl, int visibility, bool tmpl) TREE_PUBLIC (decl) = 0; DECL_WEAK (decl) = 0; DECL_COMMON (decl) = 0; + DECL_COMDAT (decl) = false; if (TREE_CODE (decl) == FUNCTION_DECL || TREE_CODE (decl) == VAR_DECL) { @@ -2215,9 +2216,12 @@ constrain_visibility_for_template (tree decl, tree targs) tree arg = TREE_VEC_ELT (args, i-1); if (TYPE_P (arg)) vis = type_visibility (arg); - else if (TREE_TYPE (arg) && POINTER_TYPE_P (TREE_TYPE (arg))) + else { - STRIP_NOPS (arg); + if (REFERENCE_REF_P (arg)) + arg = TREE_OPERAND (arg, 0); + if (TREE_TYPE (arg)) + STRIP_NOPS (arg); if (TREE_CODE (arg) == ADDR_EXPR) arg = TREE_OPERAND (arg, 0); if (VAR_OR_FUNCTION_DECL_P (arg)) diff --git a/gcc/testsuite/g++.dg/abi/anon4.C b/gcc/testsuite/g++.dg/abi/anon4.C new file mode 100644 index 000000000000..088ba9940193 --- /dev/null +++ b/gcc/testsuite/g++.dg/abi/anon4.C @@ -0,0 +1,41 @@ +// PR c++/65209 +// { dg-final { scan-assembler-not "comdat" } } + +// Everything involving the anonymous namespace bits should be private, not +// COMDAT. + +struct Bar +{ + static Bar *self(); + char pad[24]; +}; + +template +struct BarGlobalStatic +{ + Bar *operator()() { return holderFunction(); } +}; + +namespace { + namespace Q_QGS_s_self { + inline Bar *innerFunction() { + static struct Holder { + Bar value; + ~Holder() {} + } holder; + return &holder.value; + } + } +} +static BarGlobalStatic s_self; + +Bar *Bar::self() +{ + return s_self(); +} + +int main(int argc, char *argv[]) +{ + Bar* bar = Bar::self(); + return 0; +}