The concepts merge brought this bit @@ -26326,9 +26559,9 @@ build_non_dependent_expr (tree expr) unexpected recursive instantiations. */ && !parsing_nsdmi () /* Don't do this during concept expansion either and for - the same reason. */ - && !expanding_concept ()) - fold_non_dependent_expr (expr, tf_none); + the same reason. */ + && !parsing_constraint_expression_p ()) + fold_non_dependent_expr (expr);
STRIP_ANY_LOCATION_WRAPPER (expr); (which I'm not finding in the ChangeLog). Dropping tf_none means that fold_non_dependent_expr will use tf_warning_or_error by default, and in this test that causes an error: template<bool> struct cond; template<int> struct S { void f(int i) { cond<__builtin_constant_p(i)>(); } }; S<1> s; where it complains that cond<false> is incomplete. Which it is, but we're not actually instantiating the function f, so we need not issue an error. It's broken a bunch of tests if --enable-checking=extra is in effect. This patch brings that tf_none back. We will still complain if we do instantiate f. Bootstrapped/regtested on x86_64-linux, ok for trunk? 2019-10-10 Marek Polacek <pola...@redhat.com> PR c++/92049 - extra error with -fchecking=2. * pt.c (build_non_dependent_expr): Call fold_non_dependent_expr with tf_none. * g++.dg/template/builtin2.C: New test. diff --git gcc/cp/pt.c gcc/cp/pt.c index 84464436991..12bab062e61 100644 --- gcc/cp/pt.c +++ gcc/cp/pt.c @@ -27063,7 +27063,7 @@ build_non_dependent_expr (tree expr) /* Don't do this during concept processing either and for the same reason. */ && !processing_constraint_expression_p ()) - fold_non_dependent_expr (expr); + fold_non_dependent_expr (expr, tf_none); STRIP_ANY_LOCATION_WRAPPER (expr); diff --git gcc/testsuite/g++.dg/template/builtin2.C gcc/testsuite/g++.dg/template/builtin2.C new file mode 100644 index 00000000000..d4d9d2ef3a4 --- /dev/null +++ gcc/testsuite/g++.dg/template/builtin2.C @@ -0,0 +1,5 @@ +// PR c++/92049 - extra error with -fchecking=2. +// { dg-do compile { target c++11 } } +// { dg-additional-options "-fchecking=2" } + +#include "builtin1.C"