diff mbox series

[C++] PR c++/92446 - deduction of class NTTP.

Message ID 20191211164708.22749-1-jason@redhat.com
State New
Headers show
Series [C++] PR c++/92446 - deduction of class NTTP. | expand

Commit Message

Jason Merrill Dec. 11, 2019, 4:47 p.m. UTC
Another place we need to look through the VIEW_CONVERT_EXPR we add to make a
use of a class NTTP have const type.

Tested x86_64-pc-linux-gnu, applying to trunk.

	* pt.c (deducible_expression): Look through VIEW_CONVERT_EXPR.
---
 gcc/cp/pt.c                                  |  2 +-
 gcc/testsuite/g++.dg/cpp2a/nontype-class26.C | 13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp2a/nontype-class26.C


base-commit: 945f2b19497eff52ef44923d291bf0fdba043299
diff mbox series

Patch

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index d8ab26ec675..6f658de28ed 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 00000000000..315e0ac2309
--- /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 {});
+}