From: Kamlesh Kumar <kamleshbhalui@gmail.com>
To: jason@redhat.com
Cc: polacek@redhat.com, gcc-patches@gcc.gnu.org, marxin@gcc.gnu.org,
Kamlesh Kumar <kamleshbhalui@gmail.com>
Subject: [PATCH v2] [PR91979] Updated the fix:
Date: Sat, 02 Nov 2019 03:48:00 -0000 [thread overview]
Message-ID: <20191102034743.2620-1-kamleshbhalui@gmail.com> (raw)
In-Reply-To: <e29c119e-9efc-7f0b-6ba4-42223a0a3105@redhat.com>
Changlogs
gcc
------
2019-11-02 Kamlesh Kumar <kamleshbhalui@gmail.com>
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-11-02 Kamlesh Kumar <kamleshbhalui@gmail.com>
* cp-demangle.c (d_expr_primary): Handle
nullptr demangling.
* testsuite/demangle-expected: Added test.
gcc/c-family
----------
2019-11-02 Kamlesh Kumar <kamleshbhalui@gmail.com>
* c-opts.c (c_common_post_options): Updated
latest_abi_version.
---
gcc/c-family/c-opts.c | 2 +-
gcc/cp/mangle.c | 4 +++-
gcc/testsuite/g++.dg/cpp0x/nullptr27.C | 2 +-
gcc/testsuite/g++.dg/cpp0x/pr91979.C | 15 +++++++++++++++
libiberty/cp-demangle.c | 11 +++++++++++
libiberty/testsuite/demangle-expected | 4 ++++
6 files changed, 35 insertions(+), 3 deletions(-)
create mode 100644 gcc/testsuite/g++.dg/cpp0x/pr91979.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/cp/mangle.c b/gcc/cp/mangle.c
index a9333b84349..234a975781e 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<class T, decltype(nullptr) = nullptr>
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 00000000000..7fcd56b27f0
--- /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 <bool, typename T = void>
+struct enable_if {};
+
+template <typename T>
+struct enable_if<true, T> { typedef T type; };
+
+template <void *P>
+void foo(typename enable_if<P == nullptr>::type* = 0) {}
+
+template void foo<(void *)0>(void *);
+
diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c
index 5b674d7d93c..3fb1c56409e 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
+ && 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 61681484d0e..f68a8a71aaf 100644
--- a/libiberty/testsuite/demangle-expected
+++ b/libiberty/testsuite/demangle-expected
@@ -1446,3 +1446,7 @@ Foo<int>()::X::fn
_ZZZ3FooIiEfvENKUlT_E_clIcEEDaS0_EN1X2fnEv
Foo<int>()::{lambda(auto:1)#1}::operator()<char>(char) const::X::fn()
Foo<int>()::{lambda(auto:1)#1}::operator()<char>(char) const::X::fn
+#PR91979 demangling nullptr expression
+
+_Z3fooILPv0EEvPN9enable_ifIXeqT_LDnEEvE4typeE
+void foo<(void*)0>(enable_if<((void*)0)==((decltype(nullptr))), void>::type*)
--
2.17.1
next prev parent reply other threads:[~2019-11-02 3:48 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-22 16:39 [PATCH][PR91979] Incorrect mangling for non-template-argument nullptr expression kamlesh kumar
2019-10-22 16:54 ` kamlesh kumar
2019-10-22 17:23 ` Marek Polacek
[not found] ` <CABKRkgjaFKpsWYDMdwgkDcZZSsMyruRn5_8tVRGhp93Gx5GVUQ@mail.gmail.com>
2019-10-22 17:53 ` kamlesh kumar
2019-10-22 18:09 ` kamlesh kumar
2019-10-23 3:36 ` [[PATCH][PR91979] handle mangling of nullptr expression ] updated the fix Kamlesh Kumar
2019-10-31 18:08 ` kamlesh kumar
2019-11-01 21:14 ` Jason Merrill
2019-11-02 3:48 ` Kamlesh Kumar [this message]
2019-11-03 8:04 ` [PATCH v2] [PR91979] Updated the fix: Jason Merrill
2019-11-03 11:43 ` [PATCH v3] Updated the Fix: Kamlesh Kumar
2019-11-04 23:35 ` Jason Merrill
2020-01-12 13:31 ` Iain Sandoe
2020-01-12 14:39 ` Iain Sandoe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191102034743.2620-1-kamleshbhalui@gmail.com \
--to=kamleshbhalui@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jason@redhat.com \
--cc=marxin@gcc.gnu.org \
--cc=polacek@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).