aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2020-07-09 13:47:13 -0400
committerPatrick Palka <ppalka@redhat.com>2020-07-09 13:47:13 -0400
commit614662064ad4993a2aaecf190e7399ac5279e78e (patch)
tree5ff778f4aeb96e50d62364516bafff6a24504fda /gcc
parentfab263ab0fc10ea08409b80afa7e8569438b8d28 (diff)
downloadgcc-614662064ad4993a2aaecf190e7399ac5279e78e.zip
gcc-614662064ad4993a2aaecf190e7399ac5279e78e.tar.gz
gcc-614662064ad4993a2aaecf190e7399ac5279e78e.tar.bz2
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) <case PARM_DECL>: 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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/constexpr.c1
-rw-r--r--gcc/testsuite/g++.dg/template/incomplete12.C9
2 files changed, 10 insertions, 0 deletions
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index ff78ebd..97dcc1b 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 0000000..335e535
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/incomplete12.C
@@ -0,0 +1,9 @@
+// PR c++/96132
+// { dg-do compile }
+
+template <int> class a;
+
+template <int b> class c {
+ a<b> e;
+ void operator=(c d) { e = d; }
+};