From patchwork Tue Oct 22 16:30:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: kamlesh kumar X-Patchwork-Id: 1181497 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-511515-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="vmFCCpKt"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="SlCYpLfE"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46yJsc0y0Lz9sP3 for ; Wed, 23 Oct 2019 03:30:58 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=fnjTthloTOyWUvsm2GaPpaktl0a8bEGiyJ5woQi+7PLdif 6oB+Pk2PaRICNlXiF2q6C8hEKbyAEWct0sGeKEeuTlLKIs12JosUE0jCeaGCV2S2 xy2yX8RQBpitRYSHnRT5AQudFQYy3af4H6YKF1QbCsoj+P/eNL4DgFE2rjT4s= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=RBmxSvIpurxOVQJvTd/7asielyo=; b=vmFCCpKtTrkSDT0TE4Jp gDI9v7+568sYQ+Sn2fgdRHEtpYU+TNXkxif3c0EPAzKQovfJn87KiF6YPC1dk/Jx BxwgqcAeRCh2BkmUIITWDFW/COYyaMlUTAfI2H3noZuthjfmCDD8YFXAG+kjy5aN HEeMIHV1v8t7S8xfYUi2zFU= Received: (qmail 2354 invoked by alias); 22 Oct 2019 16:30:50 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 119700 invoked by uid 89); 22 Oct 2019 16:30:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.0 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=UD:type, H*c:alternative X-HELO: mail-io1-f66.google.com Received: from mail-io1-f66.google.com (HELO mail-io1-f66.google.com) (209.85.166.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 22 Oct 2019 16:30:40 +0000 Received: by mail-io1-f66.google.com with SMTP id c25so21137291iot.12; Tue, 22 Oct 2019 09:30:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=TNcLvjRzDsNig9mHdvWnZQpD1z0oI8qtYXQG12ka9XI=; b=SlCYpLfE7DokOINve4GVF+AvG/odj4EBf7fC8xxQJlvkHIujsI587nKjYhHoPl4pzt uYcoiXJYS71zGcIjldySh/0zpoxcpd4+Ez/hPIAZZJRaLnR3T707nMrVDlj60kN6rWCN tvXsGIi9oFY6uAqDGyLoGsEmSnTL6hvzAF+aPkbbhghSskUE/CzDL2KQAYiWKCTf0NzU IpoWPbFqmMs1+bXy9vIJ27upoywdOkKvb18nOskHvGRufiSyMyz2MCZsnbL6yu0vh/c0 3gHlf9nBlk1J4VqLz9uGoS+w5m11K1YmSEA5ETlCaHPH6UzCBAtukdGwRGb+/mDI40kH evIA== MIME-Version: 1.0 From: kamlesh kumar Date: Tue, 22 Oct 2019 22:00:19 +0530 Message-ID: Subject: [PATCH][PR91979] Incorrect mangling for non-template-argument nullptr expression To: gcc-patches@gcc.gnu.org, "jason@redhat.com" , polacek@redhat.com, marxin@gcc.gnu.org X-IsSubscribed: yes bootstrap and regtested on x86_64. Changelog: gcc ------ 2019-10-22 Kamlesh Kumar PR c++/91979 - mangling nullptr expression * mangle.c (write_template_arg_literal): Handle nullptr mangling. * testsuite/g++.dg/cpp0x/nullptr27.C: Modify Test. * testsuite/g++.dg/cpp0x/pr91979.C: New Test. libiberty ----------- 2019-10-22 Kamlesh Kumar * cp-demangle.c (d_expr_primary): Handle nullptr demangling. * testsuite/demangle-expected: Added test. ========================================================= void>::type*) ./Kamlesh 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); 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..3e6b6fb 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))),