aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorKamlesh Kumar <kamleshbhalui@gmail.com>2019-11-04 23:24:25 +0000
committerJason Merrill <jason@gcc.gnu.org>2019-11-04 18:24:25 -0500
commite0c866ddfdb500cacefee4e37fb3e85521c55623 (patch)
tree97bd2e1b1e838cc820f21aaee225bf416616c1e3 /gcc
parent04373f9288435fa2980dda99ad988fa5ce99331a (diff)
downloadgcc-e0c866ddfdb500cacefee4e37fb3e85521c55623.zip
gcc-e0c866ddfdb500cacefee4e37fb3e85521c55623.tar.gz
gcc-e0c866ddfdb500cacefee4e37fb3e85521c55623.tar.bz2
PR c++/91979 - mangling nullptr expression
2019-11-04 Kamlesh Kumar <kamleshbhalui@gmail.com> gcc/cp * cp/mangle.c (write_template_arg_literal): Handle nullptr mangling. gcc * common.opt (-fabi-version): Document =14. * doc/invoke.texi (C++ Dialect Options): Likewise. gcc/c-family * c-opts.c (c_common_post_options): Update latest_abi_version. libiberty * cp-demangle.c (d_expr_primary): Handle nullptr demangling. * testsuite/demangle-expected: Added test. From-SVN: r277801
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/c-family/ChangeLog5
-rw-r--r--gcc/c-family/c-opts.c2
-rw-r--r--gcc/common.opt2
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/mangle.c4
-rw-r--r--gcc/doc/invoke.texi3
-rw-r--r--gcc/testsuite/g++.dg/abi/macro0.C2
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/nullptr27.C2
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/nullptr43.C9
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/nullptr44.C15
11 files changed, 51 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 254b395..e726ff6 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2019-11-04 Kamlesh Kumar <kamleshbhalui@gmail.com>
+
+ * common.opt (-fabi-version): Document =14.
+ * doc/invoke.texi (C++ Dialect Options): Likewise.
+
2019-11-04 Aldy Hernandez <aldyh@redhat.com>
* tree-vrp.c (value_range_base::set): Do not special case pointers.
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 9e93911..d954245 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,8 @@
+2019-11-04 Kamlesh Kumar <kamleshbhalui@gmail.com>
+
+ * c-opts.c (c_common_post_options): Update
+ latest_abi_version.
+
2019-11-02 Jakub Jelinek <jakub@redhat.com>
* c-common.h (c_omp_get_context_selector): Remove.
diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c
index 0fffe60..d4c77be 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 cc279f4..fdd923e 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/ChangeLog b/gcc/cp/ChangeLog
index 7c22a53..0f75716 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2019-11-04 Kamlesh Kumar <kamleshbhalui@gmail.com>
+
+ PR c++/91979 - mangling nullptr expression
+ * cp/mangle.c (write_template_arg_literal): Handle nullptr
+ mangling.
+
2019-11-04 Jason Merrill <jason@redhat.com>
* typeck.c (check_return_expr): Avoid redundant error.
diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c
index a9333b8..0ac0451 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/doc/invoke.texi b/gcc/doc/invoke.texi
index bf3ea3f..cf7cf20 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -2413,6 +2413,9 @@ trivial move constructor.
Version 13, which first appeared in G++ 8.2, fixes the accidental
change in version 12.
+Version 14, which first appeared in G++ 10, corrects the mangling of
+the nullptr expression.
+
See also @option{-Wabi}.
@item -fabi-compat-version=@var{n}
diff --git a/gcc/testsuite/g++.dg/abi/macro0.C b/gcc/testsuite/g++.dg/abi/macro0.C
index 01a3541..0810600 100644
--- a/gcc/testsuite/g++.dg/abi/macro0.C
+++ b/gcc/testsuite/g++.dg/abi/macro0.C
@@ -1,6 +1,6 @@
// This testcase will need to be kept in sync with c_common_post_options.
// { dg-options "-fabi-version=0" }
-#if __GXX_ABI_VERSION != 1013
+#if __GXX_ABI_VERSION != 1014
#error "Incorrect value of __GXX_ABI_VERSION"
#endif
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<class T, decltype(nullptr) = nullptr>
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 0000000..fbdb6cd
--- /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<class T, decltype(nullptr) = nullptr>
+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 0000000..9ceba14
--- /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 <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 *);
+