public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Giuliano Belinassi <giulianob@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc/devel/autopar_devel] c++: Partially revert fix for PR c++/95497 [PR96132]
Date: Sat, 22 Aug 2020 23:29:10 +0000 (GMT)	[thread overview]
Message-ID: <20200822232910.C1D8D387087B@sourceware.org> (raw)

https://gcc.gnu.org/g:9872b77784d7d71f6d458ef11f0af6ad772a7dff

commit 9872b77784d7d71f6d458ef11f0af6ad772a7dff
Author: Patrick Palka <ppalka@redhat.com>
Date:   Thu Jul 9 13:47:13 2020 -0400

    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.

Diff:
---
 gcc/cp/constexpr.c                           | 1 +
 gcc/testsuite/g++.dg/template/incomplete12.C | 9 +++++++++
 2 files changed, 10 insertions(+)

diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index ff78ebda2dc..97dcc1b1d10 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 00000000000..335e5356874
--- /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; }
+};


                 reply	other threads:[~2020-08-22 23:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200822232910.C1D8D387087B@sourceware.org \
    --to=giulianob@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).