From 56f05abd0f957e41edf3ad3bfd8850c90d1fd89d Mon Sep 17 00:00:00 2001 From: Dodji Seketeli Date: Wed, 14 Dec 2011 08:46:13 +0000 Subject: [PATCH] PR c++/51476 - ICE on PTRMEM_CST as template argument in c++11 gcc/cp/ PR c++/51476 * pt.c (convert_nontype_argument): Don't call maybe_constant_value for PTRMEM_CST nodes. gcc/testsuite/ PR c++/51476 * g++.dg/cpp0x/ptrmem-cst-arg1.C: New test. From-SVN: r182324 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/pt.c | 10 +++++++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/ptrmem-cst-arg1.C | 9 +++++++++ 4 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/ptrmem-cst-arg1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d32613387ea..5b818e9f78a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2011-12-14 Dodji Seketeli + + PR c++/51476 + * pt.c (convert_nontype_argument): Don't call maybe_constant_value + for PTRMEM_CST nodes. + 2011-12-13 Jason Merrill PR c++/51406 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 3b0cb236dfa..66d4c3fb7fe 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -5720,11 +5720,15 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain) to a null value, but otherwise still need to be of a specific form. */ if (cxx_dialect >= cxx0x) { - if (INTEGRAL_OR_ENUMERATION_TYPE_P (type)) + if (TREE_CODE (expr) == PTRMEM_CST) + /* A PTRMEM_CST is already constant, and a valid template + argument for a parameter of pointer to member type, we just want + to leave it in that form rather than lower it to a + CONSTRUCTOR. */; + else if (INTEGRAL_OR_ENUMERATION_TYPE_P (type)) expr = maybe_constant_value (expr); else if (TYPE_PTR_P (type) - || (TYPE_PTR_TO_MEMBER_P (type) - && TREE_CODE (expr) != PTRMEM_CST)) + || TYPE_PTR_TO_MEMBER_P (type)) { tree folded = maybe_constant_value (expr); if (TYPE_PTR_P (type) ? integer_zerop (folded) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e22d1147de7..93c73776565 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-12-14 Dodji Seketeli + + PR c++/51476 + * g++.dg/cpp0x/ptrmem-cst-arg1.C: New test. + 2011-12-13 Jason Merrill PR c++/51406 diff --git a/gcc/testsuite/g++.dg/cpp0x/ptrmem-cst-arg1.C b/gcc/testsuite/g++.dg/cpp0x/ptrmem-cst-arg1.C new file mode 100644 index 00000000000..b6c81d5f463 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/ptrmem-cst-arg1.C @@ -0,0 +1,9 @@ +// Origin PR c++/51476 +// { dg-options "-std=c++11" } + +template struct A {}; +struct B +{ + int i; + A<&B::i> a; // { dg-error "could not convert template argument" } +};