From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 108118 invoked by alias); 14 Sep 2015 17:37:04 -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 108071 invoked by uid 89); 14 Sep 2015 17:37:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.0 required=5.0 tests=AWL,BAYES_00,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; Mon, 14 Sep 2015 17:37:02 +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 2227EA91 for ; Mon, 14 Sep 2015 17:37:01 +0000 (UTC) Received: from [10.10.116.16] (ovpn-116-16.rdu2.redhat.com [10.10.116.16]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8EHb0kT026398 for ; Mon, 14 Sep 2015 13:37:00 -0400 Subject: Re: C++ PATCH for c++/44282 (ia32 calling convention attributes and mangling) To: "gcc-patches@gcc.gnu.org" References: <556DA9CC.7010004@redhat.com> <556F6CE1.50606@redhat.com> From: Jason Merrill Message-ID: <55F705BC.2020308@redhat.com> Date: Mon, 14 Sep 2015 17:41:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <556F6CE1.50606@redhat.com> Content-Type: multipart/mixed; boundary="------------090804080706040504080305" X-SW-Source: 2015-09/txt/msg00953.txt.bz2 This is a multi-part message in MIME format. --------------090804080706040504080305 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 164 It occurred to me that we weren't warning about this with -Wabi and a lower -fabi-version. This patch fixes that. Tested x86_64-pc-linux-gnu, applying to trunk. --------------090804080706040504080305 Content-Type: text/x-patch; name="44282-3.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="44282-3.patch" Content-length: 3023 commit e924f74640ecd18240fb514f99b0d5b5ceeeffb7 Author: Jason Merrill Date: Wed Sep 2 16:32:15 2015 -0400 PR c++/44282 * mangle.c (write_CV_qualifiers_for_type): Also warn about regparm mangling with lower -fabi-version. diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index 342cb93..2640d52 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -2196,7 +2196,7 @@ write_CV_qualifiers_for_type (const tree type) We don't do this with classes and enums because their attributes are part of their definitions, not something added on. */ - if (abi_version_at_least (10) && !OVERLOAD_TYPE_P (type)) + if (!OVERLOAD_TYPE_P (type)) { auto_vec vec; for (tree a = TYPE_ATTRIBUTES (type); a; a = TREE_CHAIN (a)) @@ -2207,31 +2207,34 @@ write_CV_qualifiers_for_type (const tree type) && !is_attribute_p ("abi_tag", name)) vec.safe_push (a); } - vec.qsort (attr_strcmp); - while (!vec.is_empty()) + if (abi_version_crosses (10) && !vec.is_empty ()) + G.need_abi_warning = true; + if (abi_version_at_least (10)) { - tree a = vec.pop(); - const attribute_spec *as - = lookup_attribute_spec (get_attribute_name (a)); - - write_char ('U'); - write_unsigned_number (strlen (as->name)); - write_string (as->name); - if (TREE_VALUE (a)) + vec.qsort (attr_strcmp); + while (!vec.is_empty()) { - write_char ('I'); - for (tree args = TREE_VALUE (a); args; - args = TREE_CHAIN (args)) + tree a = vec.pop(); + const attribute_spec *as + = lookup_attribute_spec (get_attribute_name (a)); + + write_char ('U'); + write_unsigned_number (strlen (as->name)); + write_string (as->name); + if (TREE_VALUE (a)) { - tree arg = TREE_VALUE (args); - write_template_arg (arg); + write_char ('I'); + for (tree args = TREE_VALUE (a); args; + args = TREE_CHAIN (args)) + { + tree arg = TREE_VALUE (args); + write_template_arg (arg); + } + write_char ('E'); } - write_char ('E'); + + ++num_qualifiers; } - - ++num_qualifiers; - if (abi_version_crosses (10)) - G.need_abi_warning = true; } } diff --git a/gcc/testsuite/g++.dg/abi/mangle-regparm1a.C b/gcc/testsuite/g++.dg/abi/mangle-regparm1a.C new file mode 100644 index 0000000..bfa6c9b --- /dev/null +++ b/gcc/testsuite/g++.dg/abi/mangle-regparm1a.C @@ -0,0 +1,21 @@ +// { dg-do run { target { { i?86-*-* x86_64-*-* } && ia32 } } } +// { dg-options "-fabi-version=8 -Wabi -save-temps" } +// { dg-final { scan-assembler "_Z18IndirectExternCallIPFviiEiEvT_T0_S3_" } } + +template +void IndirectExternCall(F f, T t1, T t2) { // { dg-warning "mangled name" } + typedef F (*WrapF)(F); + f (t1, t2); +} + +__attribute__((regparm(3), stdcall)) +void regparm_func (int i, int j) +{ + if (i != 24 || j != 42) + __builtin_abort(); +} + +int main() +{ + IndirectExternCall (regparm_func, 24, 42); +} --------------090804080706040504080305--