aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2019-12-11 11:48:22 -0500
committerJason Merrill <jason@gcc.gnu.org>2019-12-11 11:48:22 -0500
commit3e7a892cc5bdeb5518888f2ca176d96cc720ec5f (patch)
treed0cd4fff424ab21c127b182c3a10fdf35968c0f9
parent0a22f996399c968efe9bfec96bd9f87ee537be12 (diff)
downloadgcc-3e7a892cc5bdeb5518888f2ca176d96cc720ec5f.zip
gcc-3e7a892cc5bdeb5518888f2ca176d96cc720ec5f.tar.gz
gcc-3e7a892cc5bdeb5518888f2ca176d96cc720ec5f.tar.bz2
PR c++/92446 - deduction of class NTTP.
Another place we need to look through the VIEW_CONVERT_EXPR we add to make a use of a class NTTP have const type. * pt.c (deducible_expression): Look through VIEW_CONVERT_EXPR. From-SVN: r279228
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/pt.c2
-rw-r--r--gcc/testsuite/g++.dg/cpp2a/nontype-class26.C13
3 files changed, 19 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index c776054..ad08ff0 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2019-12-11 Jason Merrill <jason@redhat.com>
+
+ PR c++/92446 - deduction of class NTTP.
+ * pt.c (deducible_expression): Look through VIEW_CONVERT_EXPR.
+
2019-12-10 Jason Merrill <jason@redhat.com>
PR c++/92847 - C++20 comparison ambiguity with class template.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index d8ab26e..6f658de 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -21183,7 +21183,7 @@ static bool
deducible_expression (tree expr)
{
/* Strip implicit conversions. */
- while (CONVERT_EXPR_P (expr))
+ while (CONVERT_EXPR_P (expr) || TREE_CODE (expr) == VIEW_CONVERT_EXPR)
expr = TREE_OPERAND (expr, 0);
return (TREE_CODE (expr) == TEMPLATE_PARM_INDEX);
}
diff --git a/gcc/testsuite/g++.dg/cpp2a/nontype-class26.C b/gcc/testsuite/g++.dg/cpp2a/nontype-class26.C
new file mode 100644
index 0000000..315e0ac
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/nontype-class26.C
@@ -0,0 +1,13 @@
+// { dg-do compile { target c++2a } }
+
+struct p { unsigned p_ {}; };
+
+template <p i> struct pp {};
+struct qq : public pp <p {}> {};
+
+template <p i> int f (pp <i> const &);
+
+int main ()
+{
+ return f (qq {});
+}