This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [[PATCH][PR91979] handle mangling of nullptr expression ] updated the fix


On 10/31/19 2:06 PM, kamlesh kumar wrote:
Jason,
Can you please review this,
let me know how can we handle -fabi-version?

We should bump latest_abi_version in c-opts.c and use abi_version_at_least to control this change.

On Wed, Oct 23, 2019 at 7:55 AM Kamlesh Kumar <kamleshbhalui@gmail.com> wrote:

---
  gcc/cp/mangle.c                        |  3 ++-
  gcc/testsuite/g++.dg/cpp0x/nullptr27.C |  2 +-
  gcc/testsuite/g++.dg/cpp0x/pr91979.C   | 15 +++++++++++++++
  libiberty/cp-demangle.c                | 10 ++++++++++
  libiberty/testsuite/demangle-expected  |  4 ++++
  5 files changed, 32 insertions(+), 2 deletions(-)
  create mode 100644 gcc/testsuite/g++.dg/cpp0x/pr91979.C

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<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 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 <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 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)

This line is too long and needs more spaces: before the ( and after commas.

+        {
+          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<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*)
--
1.8.5.6



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]