From patchwork Thu Feb 21 23:35:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 1046501 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-496848-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="v/E1Nlv/"; 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 4459p30nDqz9s4Z for ; Fri, 22 Feb 2019 10:35:54 +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:subject:message-id:mime-version:content-type; q=dns; s= default; b=PuGSsoPRB8rEoQTtaEB/Fb4Fg7lui5kgn4k2P17WNPPcFYMIhQ6y2 xraOER+u040YDie1WzT7FGh1+NrYgyzpaoXTEJ5V4gKMoS4LIMOaIOX0PfAiWY2r XzPnSv9nM0yHHJ1LjAt2F3POo47oskocFIIP3vSoid09KB+cMWGyQY= 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:subject:message-id:mime-version:content-type; s= default; bh=ztODmc/UevyVdZ+a1VPNKBv99CE=; b=v/E1Nlv/Y58zEUixGiq9 SbHAnDNy/zPgG9TZmNHXu3p64xePJHNA1fUZpb0RYrqqqtoo9TorKEvHNxSYrDqt MCHP5/HcSa8SmPQ0qIR1Aot+2W2Cdqs8B715Eyk7P0XPHTTcc8cL4vKBq/JG5OIJ zYI9hes6fr14g9Az0ZRrTNg= Received: (qmail 74964 invoked by alias); 21 Feb 2019 23:35:47 -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 74933 invoked by uid 89); 21 Feb 2019 23:35:47 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=check_narrowing, sk:explici, beforehand, sk:build_e X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 21 Feb 2019 23:35:45 +0000 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BC80B8762E for ; Thu, 21 Feb 2019 23:35:44 +0000 (UTC) Received: from redhat.com (ovpn-123-167.rdu2.redhat.com [10.10.123.167]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5074D1001DD3; Thu, 21 Feb 2019 23:35:44 +0000 (UTC) Date: Thu, 21 Feb 2019 18:35:43 -0500 From: Marek Polacek To: GCC Patches , Jason Merrill Subject: C++ PATCH for c++/89420 - ICE with CAST_EXPR in explicit-specifier Message-ID: <20190221233543.GH20014@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) We were ICEing because we called build_converted_constant_expr on an expression that wasn't value-dependent, but it still contained template codes, and that didn't work too well because check_narrowing calls maybe_constant_value. The fix is to instantiate the expression before converting it. I guess let's also use 'complain'. Also, when calling value_dependent_expression_p, we don't have to check processing_template_decl beforehand. Bootstrapped/regtested on x86_64-linux, ok for trunk? 2019-02-21 Marek Polacek PR c++/89420 - ICE with CAST_EXPR in explicit-specifier. * decl.c (build_explicit_specifier): Don't check processing_template_decl. Call instantiate_non_dependent_expr_sfinae before build_converted_constant_expr instead of calling instantiate_non_dependent_expr after it. * g++.dg/cpp2a/explicit14.C: New test. diff --git gcc/cp/decl.c gcc/cp/decl.c index 612afbacd27..83e2b3efa44 100644 --- gcc/cp/decl.c +++ gcc/cp/decl.c @@ -16687,12 +16687,12 @@ require_deduced_type (tree decl, tsubst_flags_t complain) tree build_explicit_specifier (tree expr, tsubst_flags_t complain) { - if (processing_template_decl && value_dependent_expression_p (expr)) + if (value_dependent_expression_p (expr)) /* Wait for instantiation, tsubst_function_decl will handle it. */ return expr; + expr = instantiate_non_dependent_expr_sfinae (expr, complain); expr = build_converted_constant_expr (boolean_type_node, expr, complain); - expr = instantiate_non_dependent_expr (expr); expr = cxx_constant_value (expr); return expr; } diff --git gcc/testsuite/g++.dg/cpp2a/explicit14.C gcc/testsuite/g++.dg/cpp2a/explicit14.C new file mode 100644 index 00000000000..9c3acc32ac4 --- /dev/null +++ gcc/testsuite/g++.dg/cpp2a/explicit14.C @@ -0,0 +1,11 @@ +// PR c++/89420 +// { dg-do compile { target c++2a } } + +template +struct S { + explicit(int(1)) S(int); + explicit(int{1}) S(int, int); +}; + +S s(1); +S s2(1, 2);