From patchwork Fri Nov 8 09:14:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1191754 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=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-512788-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="k3iorMUW"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="LSPTTm/p"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 478ZNs623dz9sP3 for ; Fri, 8 Nov 2019 20:15:07 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type:content-transfer-encoding; q=dns; s=default; b=ssl xoIY5Cvly5xP8Q0OSJXhvXhLbKB1TUW3m6VuNSjORlL38fXHt9r5w9gPM8Vx2Lxf Uk5ydLxr9JuHS7sLSs1IZ2sY8Jng13/mCmSQ4I5ISW8EPHlzWW6vILKR2eLSHh5a NWhbqtsaZ4XOwJmokiON/WmOPVEePJ8f7bvw7npo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type:content-transfer-encoding; s=default; bh=MvGyTT7eC vfts1j5eqEjfwdHtHE=; b=k3iorMUWxoiinffrmRVNvprpjAKAvmPvEXScDdazb 5jwVtcAVr8eRtjbu7YWxM648Qk7ES9h+RNFPabfVd9KdgIguNzY8VVAvCJq+A1Cw Eg4I0ryOk+I/o5PdV6Ru+HuM5DOwKDHwzwcKIQHkJ+Scwck3fCwpqAtffAmzqikm XU= Received: (qmail 64741 invoked by alias); 8 Nov 2019 09:15:00 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 64732 invoked by uid 89); 8 Nov 2019 09:15:00 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-7.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=DECL_INITIAL, decl_initial X-HELO: us-smtp-delivery-1.mimecast.com Received: from us-smtp-2.mimecast.com (HELO us-smtp-delivery-1.mimecast.com) (205.139.110.61) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 08 Nov 2019 09:14:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573204497; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=VLm5y/hUjcexAEzLzqvWY8PzpMljnxxcM4h1jUo0aNA=; b=LSPTTm/pgGwf0KZqkub+e6OjCYyhvZTRj3ggs9R0eXhBTIB7PdfbkXXc3ilDUuHxjGcspR yVFmZrhnszMAZAAtWfxNaQ+dp4F0cMrx/nm3P2gujcLcLY9rR0h4MuEpsg9/bAYTElO9qK URP4Y3t/7vfw4PHwHR1l3DLE0+hLePw= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-382-LA0X8rHqM8GcDIZmqQb_Vg-1; Fri, 08 Nov 2019 04:14:56 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 329EE8017DE for ; Fri, 8 Nov 2019 09:14:55 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.36.118.135]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BB48260C18; Fri, 8 Nov 2019 09:14:54 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id xA89Eqfl003640; Fri, 8 Nov 2019 10:14:52 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id xA89EplJ003639; Fri, 8 Nov 2019 10:14:51 +0100 Date: Fri, 8 Nov 2019 10:14:51 +0100 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: [C++ PATCH] Fix error-recovery with constexpr dtor (PR c++/92414) Message-ID: <20191108091451.GM4650@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 User-Agent: Mutt/1.11.3 (2019-02-01) X-Mimecast-Spam-Score: 0 Content-Disposition: inline X-IsSubscribed: yes Hi! We ICE on the following testcase, because DECL_INITIAL (decl) is error_mark_node due to previously reported error and cxx_eval_outermost_constant_expr is unhappy if ctx.ctor is not a CONSTRUCTOR, but error_mark_node. If the initializer is invalid, it should have been diagnosed already and there is no need to try to evaluate constexpr dtor on it. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2019-11-08 Jakub Jelinek PR c++/92414 * constexpr.c (cxx_constant_dtor): Don't call cxx_eval_outermost_constant_expr if DECL_INITIAL is erroneous. * g++.dg/cpp2a/constexpr-dtor4.C: New test. Jakub --- gcc/cp/constexpr.c.jj 2019-11-06 08:58:37.000000000 +0100 +++ gcc/cp/constexpr.c 2019-11-07 22:13:58.395840756 +0100 @@ -6024,7 +6024,8 @@ cxx_constant_value (tree t, tree decl) void cxx_constant_dtor (tree t, tree decl) { - cxx_eval_outermost_constant_expr (t, false, true, true, true, decl); + if (!error_operand_p (DECL_INITIAL (decl))) + cxx_eval_outermost_constant_expr (t, false, true, true, true, decl); } /* Helper routine for fold_simple function. Either return simplified --- gcc/testsuite/g++.dg/cpp2a/constexpr-dtor4.C.jj 2019-11-07 22:16:56.943181785 +0100 +++ gcc/testsuite/g++.dg/cpp2a/constexpr-dtor4.C 2019-11-07 22:18:16.752993443 +0100 @@ -0,0 +1,15 @@ +// PR c++/92414 +// { dg-do compile { target c++2a } } + +struct A { virtual void foo (); }; + +struct B : A { + constexpr B (int); // { dg-warning "used but never defined" } + constexpr ~B () { } +}; + +struct D : B { + constexpr D () : B (42) { } // { dg-error "used before its definition" } +}; + +constexpr D d; // { dg-message "in 'constexpr' expansion of" }