From patchwork Tue Feb 26 10:42:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 1048224 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-497024-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="bRTtLUk8"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="xdTYEeb2"; 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 447wPG5Wzsz9s2R for ; Tue, 26 Feb 2019 21:42:24 +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:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=WEJCWos69V8CRPefVwq+gpKOsZl5EJyhgcZ7VdVhl2mdtsyJj3 R8+Xoe328G5B3NQbTYTH6+CUuhM8US+8bVydx/rmzQJtB2XsbWIIjAHx7UnNsTn7 dcjnDh1Lzb2uX39D4xRXiU2Jl33cIxG1R9elmwjnzOv6e3cr0Aci3qCoA= 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:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=/36a45pPe+iKPDTKeA2vw/Lx/js=; b=bRTtLUk8tT4QHQOIyITJ xhSoNopowkJvbpKTVZ+9r6+/Ln03//tEuPn7+DcIwTFsZjyjMi8Zvu4JnCyeWl4y vHgnNcL4l+mlJjY6QAvEhyQ9GECG9vKehKJMfP/9nguc3Y8c24RoVaTutQ0/99AF XusMgs61wq+ENWyDjUzOJ+s= Received: (qmail 31079 invoked by alias); 26 Feb 2019 10:42:17 -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 30619 invoked by uid 89); 26 Feb 2019 10:42:16 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=explain X-HELO: userp2120.oracle.com Received: from userp2120.oracle.com (HELO userp2120.oracle.com) (156.151.31.85) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 26 Feb 2019 10:42:15 +0000 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x1QAcuVp134180; Tue, 26 Feb 2019 10:42:13 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=to : cc : from : subject : message-id : date : mime-version : content-type; s=corp-2018-07-02; bh=6nznuubqEPHrUPqDH5RdjV5l8GnzkxHMDUn1tfZafAM=; b=xdTYEeb2rmPzY/YDtejW5lARHa0StB2l3fl/ROs/4m77h77vo0+1Wbxw60wvCZw8inBd H2UwZ7TB/FmZpjdulz31I7wCAcf6ymtd1nWqkMjwVaQe/JoII7fzr4nc72fQK6tV5ipt DC5ot/T/rkhv8GmtgqK8YLUD9CUXcHEsun1AJzA9M2V2uYU2RnFIB0P26c+ojU0a62cP JhIpmWMSkml5gDfOF0RqSExc3SGS9bqsznJ4UpHqnb0F/I41PqUo529ZIel1UlCHf7ZJ dSHN8Tk8F5EJjqropu4+gmx7bV36lz/bDBdl1iUABFBJ1+4vrYgoU35mf99dveqWKzhG YA== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2qtxtrkq90-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Feb 2019 10:42:12 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x1QAgBn8002833 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Feb 2019 10:42:11 GMT Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x1QAgAMW022958; Tue, 26 Feb 2019 10:42:10 GMT Received: from [192.168.1.4] (/79.19.31.237) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 26 Feb 2019 02:42:09 -0800 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch/RFC] PR 88987 ("[9 Regression] ICE: unexpected expression '(bool)sm' of kind implicit_conv_expr") Message-ID: Date: Tue, 26 Feb 2019 11:42:07 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, the issue is rather easy to explain: after Alexandre' change  in r266874, which simplified the condition at the beginning of build_noexcept_spec to evaluate early all the expressions which aren't deferred or value-dependent, we obviously ICE during error-recovery on the new testcase because an expression which isn't a potential constant filters through and cxx_constant_value can't handle it.  We can avoid this in various ways - for example by adding a gate && potential_rvalue_constant_expression_p (expr) in the condition at the beginning of build_noexcept_spec and adjust/remove the final gcc_assert (which is already a bit obsolete wrt Alexandre' change). Or we can handle this earlier, in cp_parser_noexcept_specification_opt - in complete analogy, with, say, cp_parser_initializer_list - thus don't let through those expressions at all (possible variant: set expr = error_mark_node), which has the advantage of avoiding a duplicate potential_rvalue_constant_expression call (note: in the parser build_no_except_spec is called only by cp_parser_noexcept_specification_opt) All those variants pass the testsuite on x86_64-linux. Thanks, Paolo. //////////////////////////// Index: cp/parser.c =================================================================== --- cp/parser.c (revision 269187) +++ cp/parser.c (working copy) @@ -25143,7 +25143,17 @@ cp_parser_noexcept_specification_opt (cp_parser* p parser->type_definition_forbidden_message = G_("types may not be defined in an exception-specification"); - expr = cp_parser_constant_expression (parser); + bool non_constant_p; + expr + = cp_parser_constant_expression (parser, + /*allow_non_constant=*/true, + &non_constant_p); + if (non_constant_p + && !require_potential_rvalue_constant_expression (expr)) + { + expr = NULL_TREE; + return_cond = true; + } /* Restore the saved message. */ parser->type_definition_forbidden_message = saved_message; Index: testsuite/g++.dg/cpp0x/pr88987.C =================================================================== --- testsuite/g++.dg/cpp0x/pr88987.C (nonexistent) +++ testsuite/g++.dg/cpp0x/pr88987.C (working copy) @@ -0,0 +1,9 @@ +// { dg-do compile { target c++11 } } + +int sm; + +template T +pk () noexcept (sm) // { dg-error "constant expression" } +{ + return 0; +}