From patchwork Sun Jan 19 20:34:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 1225511 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-517699-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.a=rsa-sha1 header.s=default header.b=DWAAcTfb; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=LwS1hGjP; 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 4816491t8Gz9sR1 for ; Mon, 20 Jan 2020 07:35:03 +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:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=WQ7PWKQzRnpxkP2R j7kfuAQ63gC2eAmK4zTMzXAcX2sKZwX7Y0D7XDbTT3+9qlggcEB0PQP+HN6PplRl xU2mRdU6JW2Wrc4qg37YMC+v4VPvCC1jtIVLJM/GSsOxgEYGbeTRVipyP9KFZxz1 TfhHYLRI2QIIlFHEA1dDeqI0xv8= 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:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=akU//zeeetocTl//sbpfju 3L6d0=; b=DWAAcTfbjZ2gt5PgJcUeIZuPa5v+rfRf8C8b6VwgessM/ipQvq7pd9 7lh/ykKF8HdOLrIUlyjABasVks4OiKlgi596TuyC+Ja9CiqAMo2z0lghxN5L7bRp bo/VACnGoHIxY/VVbZHb13Cd0Ph1gIFGrB0KhEYQGtnPNAE9NjMzQ= Received: (qmail 42405 invoked by alias); 19 Jan 2020 20:34:54 -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 42393 invoked by uid 89); 19 Jan 2020 20:34:54 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=H*Ad:U*jason, HTo:U*jason X-HELO: us-smtp-delivery-1.mimecast.com Received: from us-smtp-1.mimecast.com (HELO us-smtp-delivery-1.mimecast.com) (207.211.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 19 Jan 2020 20:34:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579466091; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8R8VpZ3yazg9eUks4t3Y/Wfo7O4fPmgzH0rAGnYyXkg=; b=LwS1hGjPbJekYpLFLrg2UTGUA+5WSBFzyFrZlQp/rM7n6BaKpAemso2276mIoX70tg0AgA a69uiiffGIkrQYujxijuj4yCJI6EluSQ3aiD2rI980gNg4y2lXnJ9JCZvWiPoAuPtn2agQ lJ0ye0VfANVHQyiJ/HvIU7hA+5lajFI= 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-215-cARrHe_NPZSQKBoo5Oqr0Q-1; Sun, 19 Jan 2020 15:34:50 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 19DAF10054E3 for ; Sun, 19 Jan 2020 20:34:49 +0000 (UTC) Received: from pdp-11.redhat.com (ovpn-120-20.rdu2.redhat.com [10.10.120.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id A444284D9F; Sun, 19 Jan 2020 20:34:48 +0000 (UTC) From: Marek Polacek To: GCC Patches , Jason Merrill Subject: [C++ PATCH] PR c++/93324 - ICE with -Wall on constexpr if. Date: Sun, 19 Jan 2020 15:34:48 -0500 Message-Id: <20200119203448.957706-1-polacek@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com This is a crash with constexpr if, when trying to see if the call in the if-statement is std::is_constant_evaluated. cp_get_callee_fndecl_nofold can return NULL_TREE and fndecl_built_in_p doesn't expect to get a null tree, so check FNDECL first. Bootstrapped/regtested on x86_64-linux, ok for trunk? * semantics.c (is_std_constant_evaluated_p): Check fndecl. * g++.dg/cpp1z/constexpr-if33.C: New test. --- gcc/cp/semantics.c | 4 ++-- gcc/testsuite/g++.dg/cpp1z/constexpr-if33.C | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp1z/constexpr-if33.C base-commit: bcfc2227c556f2801a657ce3007374732baa8333 diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 3669b247e34..9051a2863e0 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -734,8 +734,8 @@ is_std_constant_evaluated_p (tree fn) return false; tree fndecl = cp_get_callee_fndecl_nofold (fn); - if (fndecl_built_in_p (fndecl, CP_BUILT_IN_IS_CONSTANT_EVALUATED, - BUILT_IN_FRONTEND)) + if (fndecl && fndecl_built_in_p (fndecl, CP_BUILT_IN_IS_CONSTANT_EVALUATED, + BUILT_IN_FRONTEND)) return true; if (!decl_in_std_namespace_p (fndecl)) diff --git a/gcc/testsuite/g++.dg/cpp1z/constexpr-if33.C b/gcc/testsuite/g++.dg/cpp1z/constexpr-if33.C new file mode 100644 index 00000000000..e5ef659932b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/constexpr-if33.C @@ -0,0 +1,16 @@ +// PR c++/93324 - ICE with -Wall on constexpr if. +// { dg-do compile { target c++17 } } +// { dg-options "-Wall" } + +struct { + template + static constexpr bool a() { return 0; } +} e; + +template +void d() +{ + auto c(e); + using b = decltype(c); + if constexpr (b::a<2>()); +}