From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 55145 invoked by alias); 22 Oct 2019 17:23:46 -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 55126 invoked by uid 89); 22 Oct 2019 17:23:46 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.8 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-il1-f169.google.com Received: from mail-il1-f169.google.com (HELO mail-il1-f169.google.com) (209.85.166.169) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 22 Oct 2019 17:23:44 +0000 Received: by mail-il1-f169.google.com with SMTP id u1so16177573ilq.12; Tue, 22 Oct 2019 10:23:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=PCwlR+oz9z7sugqSaf5pyg+q/ChFvANbAUH+on8yn9k=; b=C1yjKt+aMCSg8fNevowiKSGV35lWx4AmPDvpbIcAggc73+kootyCm/86alfopWAAcv L0pOr92aNq5U4g2w0o7gST0+pOLfQTZbR37VVyhoOGu/uuuOc6Qp3KxeiLbQ1/7Pg3rA O4oqZJHf5j0EMfOSOt5VQ59fbtAHZo59pRbA/Z2v9ahUkeEpMcvSG4/KknKznc+Z70yH L377UF2mkdfbNppxknuUk5+SugVHMVqC1p+fDBX4evUHjXP4yiG2+YTSbHlTOlBC6nhI 7YOYdqDSZ7K6ko0x2veoOvNXeqj4YsAZ/uj7BmjbHD6Uh4z4bZQshvo6r7Vj/tbIrTv1 jRzw== MIME-Version: 1.0 References: <20191022165434.GJ2922@redhat.com> In-Reply-To: From: kamlesh kumar Date: Tue, 22 Oct 2019 17:53:00 -0000 Message-ID: Subject: Re: [PATCH][PR91979] Incorrect mangling for non-template-argument nullptr expression To: Marek Polacek Cc: gcc-patches@gcc.gnu.org, "jason@redhat.com" , marxin@gcc.gnu.org, redi@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2019-10/txt/msg01589.txt.bz2 diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index a9333b8..334610c 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -3400,7 +3400,8 @@ write_template_arg_literal (const tree value) case INTEGER_CST: gcc_assert (!same_type_p (TREE_TYPE (value), boolean_type_node) || integer_zerop (value) || integer_onep (value)); - write_integer_cst (value); + if (!NULLPTR_TYPE_P (TREE_TYPE (value))) + write_integer_cst (value); break; case REAL_CST: diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr27.C b/gcc/testsuite/g++.dg/cpp0x/nullptr27.C index 2510dc8..edd1160 100644 --- a/gcc/testsuite/g++.dg/cpp0x/nullptr27.C +++ b/gcc/testsuite/g++.dg/cpp0x/nullptr27.C @@ -1,7 +1,7 @@ // PR c++/52706 // { dg-do compile { target c++11 } } // { dg-options "-fabi-version=0" } -// { dg-final { scan-assembler "_Z1fIDnLDn0EEiT_" } } +// { dg-final { scan-assembler "_Z1fIDnLDnEEiT_" } } template int f(T); diff --git a/gcc/testsuite/g++.dg/cpp0x/pr91979.C b/gcc/testsuite/g++.dg/cpp0x/pr91979.C new file mode 100644 index 0000000..7fcd56b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr91979.C @@ -0,0 +1,15 @@ +// PR c++/91989 +// { dg-do compile { target c++11 } } +// { dg-final { scan-assembler "_Z3fooILPv0EEvPN9enable_ifIXeqT_LDnEEvE4typeE" } } + +template +struct enable_if {}; + +template +struct enable_if { typedef T type; }; + +template +void foo(typename enable_if

::type* = 0) {} + +template void foo<(void *)0>(void *); + diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c index aa78c86..3c32b26 100644 --- a/libiberty/cp-demangle.c +++ b/libiberty/cp-demangle.c @@ -3577,6 +3577,16 @@ d_expr_primary (struct d_info *di) && type->u.s_builtin.type->print != D_PRINT_DEFAULT) di->expansion -= type->u.s_builtin.type->len; + if (type->type == DEMANGLE_COMPONENT_BUILTIN_TYPE + && strncmp(type->u.s_builtin.type->name,cplus_demangle_builtin_types[33].name,17) == 0) + { + if (d_peek_char (di) == 'E') + { + d_advance (di, 1); + return type; + } + } + /* Rather than try to interpret the literal value, we just collect it as a string. Note that it's possible to have a floating point literal here. The ABI specifies that the diff --git a/libiberty/testsuite/demangle-expected b/libiberty/testsuite/demangle-expected index f21ed00..b23a7c2 100644 --- a/libiberty/testsuite/demangle-expected +++ b/libiberty/testsuite/demangle-expected @@ -1446,3 +1446,7 @@ Foo()::X::fn _ZZZ3FooIiEfvENKUlT_E_clIcEEDaS0_EN1X2fnEv Foo()::{lambda(auto:1)#1}::operator()(char) const::X::fn() Foo()::{lambda(auto:1)#1}::operator()(char) const::X::fn +#PR91979 demangling nullptr expression + +_Z3fooILPv0EEvPN9enable_ifIXeqT_LDnEEvE4typeE +void foo<(void*)0>(enable_if<((void*)0)==((decltype(nullptr))), void>::type*) On Tue, Oct 22, 2019 at 10:50 PM kamlesh kumar wrote: > Marek, > updated the patch as per your suggestion. > Regarding -fabi-version. > this is what Jonathan said: > > This might need a new -fabi-version to preserve the old mangling for compatibility, but I'll let Jason determine that. > > > Thanks. > > > > On Tue, Oct 22, 2019 at 10:24 PM Marek Polacek wrote: > >> On Tue, Oct 22, 2019 at 10:00:19PM +0530, kamlesh kumar wrote: >> > diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c >> > index a9333b8..780da9f 100644 >> > --- a/gcc/cp/mangle.c >> > +++ b/gcc/cp/mangle.c >> > @@ -3400,7 +3400,8 @@ write_template_arg_literal (const tree value) >> > case INTEGER_CST: >> > gcc_assert (!same_type_p (TREE_TYPE (value), boolean_type_node) >> > || integer_zerop (value) || integer_onep (value)); >> > - write_integer_cst (value); >> > + if (TREE_CODE(TREE_TYPE(value)) != NULLPTR_TYPE) >> > + write_integer_cst (value); >> >> Please use NULLPTR_TYPE_P. >> >> Does this warrant a new -fabi-version? >> >> Marek >> >>