From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 99380 invoked by alias); 3 Jun 2015 21:08:59 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 99358 invoked by uid 89); 3 Jun 2015 21:08:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_40,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 03 Jun 2015 21:08:57 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 4A319345B49; Wed, 3 Jun 2015 21:08:56 +0000 (UTC) Received: from [10.10.116.21] ([10.10.116.21]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t53L8siH016673; Wed, 3 Jun 2015 17:08:54 -0400 Message-ID: <556F6CE1.50606@redhat.com> Date: Wed, 03 Jun 2015 21:39:00 -0000 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Uros Bizjak , "gcc-patches@gcc.gnu.org" Subject: Re: C++ PATCH for c++/44282 (ia32 calling convention attributes and mangling) References: <556DA9CC.7010004@redhat.com> In-Reply-To: <556DA9CC.7010004@redhat.com> Content-Type: multipart/mixed; boundary="------------090009050105090509020401" X-SW-Source: 2015-06/txt/msg00364.txt.bz2 This is a multi-part message in MIME format. --------------090009050105090509020401 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 119 On 06/02/2015 09:04 AM, Jason Merrill wrote: > Ugh, I thought I had dealt with that issue. Looking... Fixed thus. --------------090009050105090509020401 Content-Type: text/x-patch; name="44282-2.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="44282-2.patch" Content-length: 6062 commit 82343dca07986bd1db2759d2eca1cfd5b9728410 Author: Jason Merrill Date: Tue Jun 2 13:24:11 2015 -0400 PR c++/44282 * mangle.c (mangle_decl): Always SET_IDENTIFIER_GLOBAL_VALUE. (write_CV_qualifiers_for_type): Set G.need_abi_warning. (decl_implicit_alias_p): Split out from maybe_remove_implicit_alias. * cp-tree.h (DECL_REALLY_EXTERN): Handle null DECL_LANG_SPECIFIC. diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 9107fa6..dc595fe 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -4101,7 +4101,8 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter) (DECL_LANG_SPECIFIC (NODE)->u.base.not_really_extern) #define DECL_REALLY_EXTERN(NODE) \ - (DECL_EXTERNAL (NODE) && ! DECL_NOT_REALLY_EXTERN (NODE)) + (DECL_EXTERNAL (NODE) \ + && (!DECL_LANG_SPECIFIC (NODE) || !DECL_NOT_REALLY_EXTERN (NODE))) /* A thunk is a stub function. diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index 8fd06e3..cc5faf7 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -2205,10 +2205,6 @@ write_CV_qualifiers_for_type (const tree type) /* Mangle attributes that affect type identity as extended qualifiers. - We mangle them onto the obstack, then copy the result into a string - vector and back up the obstack. Once we've handled all of them we - sort them and write them out in order. - We don't do this with classes and enums because their attributes are part of their definitions, not something added on. */ @@ -2246,6 +2242,8 @@ write_CV_qualifiers_for_type (const tree type) } ++num_qualifiers; + if (abi_version_crosses (9)) + G.need_abi_warning = true; } } @@ -3535,11 +3533,11 @@ get_mangled_id (tree decl) return targetm.mangle_decl_assembler_name (decl, id); } -/* If DECL is a mangling alias, remove it from the symbol table and return - true; otherwise return false. */ +/* If DECL is an implicit mangling alias, return its symtab node; otherwise + return NULL. */ -bool -maybe_remove_implicit_alias (tree decl) +static symtab_node * +decl_implicit_alias_p (tree decl) { if (DECL_P (decl) && DECL_ARTIFICIAL (decl) && DECL_IGNORED_P (decl) @@ -3549,10 +3547,21 @@ maybe_remove_implicit_alias (tree decl) { symtab_node *n = symtab_node::get (decl); if (n && n->cpp_implicit_alias) - { - n->remove(); - return true; - } + return n; + } + return NULL; +} + +/* If DECL is a mangling alias, remove it from the symbol table and return + true; otherwise return false. */ + +bool +maybe_remove_implicit_alias (tree decl) +{ + if (symtab_node *n = decl_implicit_alias_p (decl)) + { + n->remove(); + return true; } return false; } @@ -3592,21 +3601,38 @@ mangle_decl (const tree decl) } SET_DECL_ASSEMBLER_NAME (decl, id); - if (G.need_abi_warning + if (id != DECL_NAME (decl) + && !DECL_REALLY_EXTERN (decl) /* Don't do this for a fake symbol we aren't going to emit anyway. */ && TREE_CODE (decl) != TYPE_DECL && !DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (decl) && !DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (decl)) { + bool set = false; + + /* Check IDENTIFIER_GLOBAL_VALUE before setting to avoid redundant + errors from multiple definitions. */ + tree d = IDENTIFIER_GLOBAL_VALUE (id); + if (!d || decl_implicit_alias_p (d)) + { + set = true; + SET_IDENTIFIER_GLOBAL_VALUE (id, decl); + } + + if (!G.need_abi_warning) + return; + /* If the mangling will change in the future, emit an alias with the future mangled name for forward-compatibility. */ int save_ver; tree id2; - SET_IDENTIFIER_GLOBAL_VALUE (id, decl); - if (IDENTIFIER_GLOBAL_VALUE (id) != decl) - inform (DECL_SOURCE_LOCATION (decl), "a later -fabi-version= (or =0) " - "avoids this error with a change in mangling"); + if (!set) + { + SET_IDENTIFIER_GLOBAL_VALUE (id, decl); + inform (DECL_SOURCE_LOCATION (decl), "a later -fabi-version= (or " + "=0) avoids this error with a change in mangling"); + } save_ver = flag_abi_version; flag_abi_version = flag_abi_compat_version; diff --git a/gcc/testsuite/g++.dg/abi/mangle-regparm.C b/gcc/testsuite/g++.dg/abi/mangle-regparm.C index e5d6f37..122d373 100644 --- a/gcc/testsuite/g++.dg/abi/mangle-regparm.C +++ b/gcc/testsuite/g++.dg/abi/mangle-regparm.C @@ -1,10 +1,11 @@ // { dg-do run { target { { i?86-*-* x86_64-*-* } && ia32 } } } +// { dg-options "-Wabi=8" } // { dg-final { scan-assembler "_Z18IndirectExternCallIPU7stdcallU7regparmILi3EEFviiEiEvT_T0_S3_" } } typedef __SIZE_TYPE__ size_t; template -void IndirectExternCall(F f, T t1, T t2) { +void IndirectExternCall(F f, T t1, T t2) { // { dg-warning "mangled name" } typedef F (*WrapF)(F); f (t1, t2); } diff --git a/gcc/testsuite/g++.dg/abi/mangle58.C b/gcc/testsuite/g++.dg/abi/mangle58.C index f9aadc2..d2c90b4 100644 --- a/gcc/testsuite/g++.dg/abi/mangle58.C +++ b/gcc/testsuite/g++.dg/abi/mangle58.C @@ -6,13 +6,13 @@ struct B { template static int cmp1(T a, T b); static int cmp2(char a, char b); // { dg-final { scan-assembler "_ZN1B1fIcEEvR1AIT_X4cmp1EE" } } - template static void f (A &); + template static void f (A &) {} // { dg-final { scan-assembler "_ZN1B1gIcEEvR1AIT_XsrS_4cmp1EE" } } - template static void g (A &); + template static void g (A &) {} // { dg-final { scan-assembler "_ZN1B1fIcEEvR1AIT_L_ZNS_4cmp2EccEE" } } - template static void f (A &); // { dg-warning "mangle" } + template static void f (A &) {} // { dg-warning "mangle" } // { dg-final { scan-assembler "_ZN1B1gIcEEvR1AIT_L_ZNS_4cmp2EccEE" } } - template static void g (A &); // { dg-warning "mangle" } + template static void g (A &) {} // { dg-warning "mangle" } }; void g() --------------090009050105090509020401--