From patchwork Thu Jul 9 17:55:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1326100 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=DXF/wXsE; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B2kNm0QXHz9sSn for ; Fri, 10 Jul 2020 03:55:36 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 366503842404; Thu, 9 Jul 2020 17:55:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 366503842404 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1594317333; bh=JoQKb/Kfsey/YV7YgGqqBgmnyVPayzYktxmLmMVkyrg=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=DXF/wXsEVuYf7YK+98ufrq4YZt3hdytXe4BYgkFKGXRrkXBoyfOecuhqpysbG35jd cpUfTpD7IonErUwfQLJbnYZb2GAUf/7QVzy52aYIPx5nZGPYyM0JNZlovo+bT+4WpP VpMxVtfgzP9MUJjTAZFebkM7eBr5khAgxn1B5pDU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by sourceware.org (Postfix) with ESMTP id 81E54384B13D for ; Thu, 9 Jul 2020 17:55:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 81E54384B13D Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-166-Uecnr9N5MPSy8m7I2YOdwQ-1; Thu, 09 Jul 2020 13:55:29 -0400 X-MC-Unique: Uecnr9N5MPSy8m7I2YOdwQ-1 Received: by mail-qt1-f198.google.com with SMTP id e4so2205086qtd.13 for ; Thu, 09 Jul 2020 10:55:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=JoQKb/Kfsey/YV7YgGqqBgmnyVPayzYktxmLmMVkyrg=; b=K91JQeDMJtGA9bDF3n6+tyhUzpfpAntgyucgK12KuIFR9lWyf1g4nJ7KDFqAZ0DxDy h2w2rHZoMiEzB42nZbHwmjNubNyndhkXARaKQJ4RLzI6cuf1IMcp9eo+GK8G6K0Krltn Hby2ve8fDMjLT2iYa01izlZWDzORI//TjfIhmz0r5Py+RjdF/hni8SxW8+VnFqCe2XMB 757AmER1/xqvVOTWO2r4Jj2YCzg5ucawj7dG5EDfotYzjFsZXF5jlXFf3nAg4s0f9fnp tiC/ct3t/pI0INij5vCfSV1JMJUxSWUYqR0TA1TvZ+FfIWt+glOYzfXiWCC07JapIjko NCpA== X-Gm-Message-State: AOAM530HGPWHStdrAy5q7A0a47E+7dTornJw6riXurOxA0BLnj6GUTeW FnXeKGfoAwQ/sKSjBDpVqPJ1bW1ZRyO6XfSJ3fuE1NI6FRWjmclIFj6b7OcwfY95CkGmJoUpk5q WMc1W7EzrTbgdPAjAZg== X-Received: by 2002:ac8:7586:: with SMTP id s6mr64664331qtq.289.1594317328687; Thu, 09 Jul 2020 10:55:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxRuMks9bK26QQ2VdVbOYo5aLiNfVDXfyaLg71es49tka18dTEwxzrHACVlji/gh7kJWBsyuw== X-Received: by 2002:ac8:7586:: with SMTP id s6mr64664308qtq.289.1594317328398; Thu, 09 Jul 2020 10:55:28 -0700 (PDT) Received: from localhost.localdomain (ool-457d493a.dyn.optonline.net. [69.125.73.58]) by smtp.gmail.com with ESMTPSA id 79sm4288063qkd.134.2020.07.09.10.55.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jul 2020 10:55:27 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [committed] c++: Partially revert fix for PR c++/95497 [PR96132] Date: Thu, 9 Jul 2020 13:55:20 -0400 Message-Id: <20200709175520.2390282-1-ppalka@redhat.com> X-Mailer: git-send-email 2.27.0.343.g4a0fcf9f76 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-17.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Patrick Palka via Gcc-patches From: Patrick Palka Reply-To: Patrick Palka Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" 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. --- gcc/cp/constexpr.c | 1 + gcc/testsuite/g++.dg/template/incomplete12.C | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 gcc/testsuite/g++.dg/template/incomplete12.C 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 class a; + +template class c { + a e; + void operator=(c d) { e = d; } +};