From: Patrick Palka Date: Thu, 9 Jul 2020 17:47:13 +0000 (-0400) Subject: c++: Partially revert fix for PR c++/95497 [PR96132] X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9872b77784d7d71f6d458ef11f0af6ad772a7dff;p=thirdparty%2Fgcc.git c++: Partially revert fix for PR c++/95497 [PR96132] I was mistaken to assume that a dependent type is necessarily incomplete, and indeed there are multiple places in the frontend where we check a type for both dependency and completeness. So this patch partially reverts the fix for PR95497, restoring the dependent_type_p check that guarded the call to is_really_empty_class below. gcc/cp/ChangeLog: PR c++/96132 * constexpr.c (potential_constant_expression_1) : Restore dependent_type_p check that guarded the call to is_really_empty_class. gcc/testsuite/ChangeLog: PR c++/96132 * g++.dg/template/incomplete12.C: New test. --- diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index ff78ebda2dc9..97dcc1b1d105 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -7444,6 +7444,7 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now, { tree type = TREE_TYPE (t); if ((processing_template_decl && !COMPLETE_TYPE_P (type)) + || dependent_type_p (type) || is_really_empty_class (type, /*ignore_vptr*/false)) /* An empty class has no data to read. */ return true; diff --git a/gcc/testsuite/g++.dg/template/incomplete12.C b/gcc/testsuite/g++.dg/template/incomplete12.C new file mode 100644 index 000000000000..335e5356874d --- /dev/null +++ b/gcc/testsuite/g++.dg/template/incomplete12.C @@ -0,0 +1,9 @@ +// PR c++/96132 +// { dg-do compile } + +template class a; + +template class c { + a e; + void operator=(c d) { e = d; } +};