]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c++/92446 - deduction of class NTTP.
authorJason Merrill <jason@redhat.com>
Fri, 13 Dec 2019 05:10:02 +0000 (00:10 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 13 Dec 2019 05:10:02 +0000 (00:10 -0500)
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: r279333

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp2a/nontype-class26.C [new file with mode: 0644]

index 19d70a3297889025cf9553847d7287c51b9b6040..bda8304df575a2ae6e278d43ee45b7b6dfae1edd 100644 (file)
@@ -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-11-06  Jason Merrill  <jason@redhat.com>
 
        PR c++/92150 - partial specialization with class NTTP.
index aa78ac980b3cfa58596a2f79372ed67069165489..0ebac069984c970bf2cf8d8db40082902f85af34 100644 (file)
@@ -20575,7 +20575,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 (file)
index 0000000..315e0ac
--- /dev/null
@@ -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 {});
+}