From patchwork Sun Nov 3 11:42:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: kamlesh kumar X-Patchwork-Id: 1188541 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-512271-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (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="GJR1jHVn"; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ff0FOUIo"; 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 475Yw72Kwbz9sPF for ; Sun, 3 Nov 2019 22:43:16 +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:from :to:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=JXQonY8YCaCiNiMiGMT9chVUIf2HGZAqxJ2e3Xby3U+7JrN2q6/1h FKjLh97yNnzjU3PARQLcv4PvU3Bv3lKiFmKxJHH71WTtgFR/c9xDazuglcR84mIV rOqb884h4DKJwedb+B5Vu7pQEEqUdQZkcY6gUXIsTC9GrITuRQXggc= 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:from :to:cc:subject:date:message-id:in-reply-to:references; s= default; bh=z3OvmjuiBAlnKHWf/OaNZrIik4w=; b=GJR1jHVnMxLnV0mkvVd8 ieJGOIlx4VSIHIeqBv7b5JHb4IjTrobzyIBCWX+6+GWa1yOkkTY65Mkhp1Sv+K0Q yM7QEkIsB4xUWQkxLrv82BpiTM0PnRG2OX1rfJL35K5DWgTkk0i5Dx5WGDQjUrQp Pk6a0z3R5K92/67YM7PXUHg= Received: (qmail 55924 invoked by alias); 3 Nov 2019 11:43:09 -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 55906 invoked by uid 89); 3 Nov 2019 11:43:09 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=corrects X-HELO: mail-pf1-f178.google.com Received: from mail-pf1-f178.google.com (HELO mail-pf1-f178.google.com) (209.85.210.178) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 03 Nov 2019 11:43:07 +0000 Received: by mail-pf1-f178.google.com with SMTP id z4so4202030pfn.12; Sun, 03 Nov 2019 03:43:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CfJf8VkufHQXaFBMjc1ePJ6gmIjAtGvS3cN+WdvgNsA=; b=ff0FOUIoym/QIIqlN1Bu82WFhrD7xjwCu4KMBXvD6WRQTURgtDfQXrisRFYEVFIPJI EuSzhJV/Cr7mpZyfiHK+Xh8bP6aB9bFQ+SN8DPs4RKEkYtmhmrJIfvYS1GdjawX6nTQy r3tkX9kkeK4Y0qFhCxKMOsRqFcLuWnH1EdNW2UOT4AckZG+W9uFN1DIc+nfJZjT4jSbx mI/fW1pg9QrJowkPJTAJRUB9//f8+LDm2JQxW+qVb5O6VVVQevOF+tgbtNYle6HkEoD+ kmpq2tFAJjO4zmYZ11KYyYdn8ZuIKogISiCvsoG7C2FHlQYTtDwcTQ8um92gjcYzgPoh 9fOA== Received: from localhost.localdomain ([2409:4071:2019:2005:2165:21cc:5399:b93d]) by smtp.googlemail.com with ESMTPSA id z18sm13794843pgv.90.2019.11.03.03.43.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Nov 2019 03:43:04 -0800 (PST) From: Kamlesh Kumar To: jason@redhat.com Cc: polacek@redhat.com, gcc-patches@gcc.gnu.org, marxin@gcc.gnu.org Subject: [PATCH v3] Updated the Fix: Date: Sun, 3 Nov 2019 17:12:49 +0530 Message-Id: <20191103114249.22001-1-kamleshbhalui@gmail.com> In-Reply-To: <20191102034743.2620-1-kamleshbhalui@gmail.com> References: <20191102034743.2620-1-kamleshbhalui@gmail.com> X-IsSubscribed: yes ChangeLog Entries: gcc/cp ------ 2019-11-02 Kamlesh Kumar PR c++/91979 - mangling nullptr expression * cp/mangle.c (write_template_arg_literal): Handle nullptr mangling. gcc ------ 2019-11-02 Kamlesh Kumar * common.opt (-fabi-version): Added Description. * testsuite/g++.dg/cpp0x/nullptr27.C: Modify Test. * testsuite/g++.dg/cpp0x/nullptr43.C: New Test. * testsuite/g++.dg/cpp0x/nullptr44.C: New Test. libiberty ----------- 2019-11-02 Kamlesh Kumar * cp-demangle.c (d_expr_primary): Handle nullptr demangling. * testsuite/demangle-expected: Added test. gcc/c-family ---------- 2019-11-02 Kamlesh Kumar * c-opts.c (c_common_post_options): Updated latest_abi_version. --- gcc/c-family/c-opts.c | 2 +- gcc/common.opt | 2 ++ gcc/cp/mangle.c | 4 +++- gcc/testsuite/g++.dg/cpp0x/nullptr27.C | 2 +- gcc/testsuite/g++.dg/cpp0x/nullptr43.C | 9 +++++++++ gcc/testsuite/g++.dg/cpp0x/nullptr44.C | 15 +++++++++++++++ libiberty/cp-demangle.c | 11 +++++++++++ libiberty/testsuite/demangle-expected | 4 ++++ 8 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/nullptr43.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/nullptr44.C diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index 0fffe60b140..d4c77be5cd5 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -937,7 +937,7 @@ c_common_post_options (const char **pfilename) /* Change flag_abi_version to be the actual current ABI level, for the benefit of c_cpp_builtins, and to make comparison simpler. */ - const int latest_abi_version = 13; + const int latest_abi_version = 14; /* Generate compatibility aliases for ABI v11 (7.1) by default. */ const int abi_compat_default = 11; diff --git a/gcc/common.opt b/gcc/common.opt index cc279f411d7..fdd923e3c35 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -951,6 +951,8 @@ Driver Undocumented ; 13: Fixes the accidental change in 12 to the calling convention for classes ; with deleted copy constructor and trivial move constructor. ; Default in G++ 8.2. +; 14: Corrects the mangling of nullptr expression. +; Default in G++ 10. ; ; Additional positive integers will be assigned as new versions of ; the ABI become the default version of the ABI. diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index a9333b84349..a32ff2a2210 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -3400,7 +3400,9 @@ 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 (!(abi_version_at_least (14) + && 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 2510dc80634..edd11606266 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/nullptr43.C b/gcc/testsuite/g++.dg/cpp0x/nullptr43.C new file mode 100644 index 00000000000..fbdb6cd8e9d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nullptr43.C @@ -0,0 +1,9 @@ +// PR c++/91979 +// { dg-do compile { target c++11 } } +// { dg-options "-fabi-version=13" } +// { dg-final { scan-assembler "_Z1fIDnLDn0EEiT_" } } + +template +int f(T); + +int i2 = f(nullptr); diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr44.C b/gcc/testsuite/g++.dg/cpp0x/nullptr44.C new file mode 100644 index 00000000000..9ceba14fc98 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nullptr44.C @@ -0,0 +1,15 @@ +// PR c++/91979 +// { 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 5b674d7d93c..3150efff80d 100644 --- a/libiberty/cp-demangle.c +++ b/libiberty/cp-demangle.c @@ -3577,6 +3577,17 @@ 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 + && strcmp (type->u.s_builtin.type->name, + cplus_demangle_builtin_types[33].name) == 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 61681484d0e..f68a8a71aaf 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*)