From d69f32911ef5f1ecdb587c4c3f30488b09c0d26c Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 13 Dec 2019 00:10:02 -0500 Subject: [PATCH] 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: r279333 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/pt.c | 2 +- gcc/testsuite/g++.dg/cpp2a/nontype-class26.C | 13 +++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp2a/nontype-class26.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 19d70a329788..bda8304df575 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2019-12-11 Jason Merrill + + PR c++/92446 - deduction of class NTTP. + * pt.c (deducible_expression): Look through VIEW_CONVERT_EXPR. + 2019-11-06 Jason Merrill PR c++/92150 - partial specialization with class NTTP. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index aa78ac980b3c..0ebac069984c 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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 index 000000000000..315e0ac23098 --- /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

struct pp {}; +struct qq : public pp

{}; + +template

int f (pp const &); + +int main () +{ + return f (qq {}); +} -- 2.47.2