From 02b0c08c2c42c6e4e53525e14953ad4099536773 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Tue, 24 Oct 2017 16:41:05 +0000 Subject: [PATCH] re PR c++/80991 (ICE with __is_trivially_constructible in template) /cp 2017-10-24 Paolo Carlini PR c++/80991 * pt.c (value_dependent_expression_p, [TRAIT_EXPR]): Handle a TREE_LIST as TRAIT_EXPR_TYPE2. /testsuite 2017-10-24 Paolo Carlini PR c++/80991 * g++.dg/ext/is_trivially_constructible5.C: New. From-SVN: r254051 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/pt.c | 17 +++++++++++++++-- gcc/testsuite/ChangeLog | 5 +++++ .../g++.dg/ext/is_trivially_constructible5.C | 12 ++++++++++++ 4 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/ext/is_trivially_constructible5.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8228c8f0a9d..e24a1949d86 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2017-10-24 Paolo Carlini + + PR c++/80991 + * pt.c (value_dependent_expression_p, [TRAIT_EXPR]): Handle + a TREE_LIST as TRAIT_EXPR_TYPE2. + 2017-10-24 Mukesh Kapoor Paolo Carlini diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index ba52f3b57a6..be39da72901 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -24019,8 +24019,21 @@ value_dependent_expression_p (tree expression) case TRAIT_EXPR: { tree type2 = TRAIT_EXPR_TYPE2 (expression); - return (dependent_type_p (TRAIT_EXPR_TYPE1 (expression)) - || (type2 ? dependent_type_p (type2) : false)); + + if (dependent_type_p (TRAIT_EXPR_TYPE1 (expression))) + return true; + + if (!type2) + return false; + + if (TREE_CODE (type2) != TREE_LIST) + return dependent_type_p (type2); + + for (; type2; type2 = TREE_CHAIN (type2)) + if (dependent_type_p (TREE_VALUE (type2))) + return true; + + return false; } case MODOP_EXPR: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 42fff12c1aa..edf21e9e8b8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-10-24 Paolo Carlini + + PR c++/80991 + * g++.dg/ext/is_trivially_constructible5.C: New. + 2017-10-24 Rainer Orth * gcc.target/i386/387-ficom-1.c: Allow for ficomp without s diff --git a/gcc/testsuite/g++.dg/ext/is_trivially_constructible5.C b/gcc/testsuite/g++.dg/ext/is_trivially_constructible5.C new file mode 100644 index 00000000000..15ea33675ed --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/is_trivially_constructible5.C @@ -0,0 +1,12 @@ +// PR c++/80991 +// { dg-do compile { target c++11 } } + +template void foo() +{ + static_assert(__is_trivially_constructible(int, int), ""); +} + +void bar() +{ + foo(); +} -- 2.30.2