From patchwork Fri Apr 13 09:05:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 897893 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-476329-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="eKBqU2YA"; 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 40MsMG3Ddgz9s0W for ; Fri, 13 Apr 2018 19:05:59 +1000 (AEST) 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=gQtMnxkP3FZzUVuAHUQSD+GOU0+4JA6k44Q2ERs20WYG6b/oNz ketm4zmSkpLbRiW0ST354sfTV4iM/CQGvx9BBIcakXWxZrYemVA9/XDzhnvSrrJd IU+5jgsx2F0sbd6NN+mn42ckXEthCq5um2744jOGBch87qSuSlanhazp4= 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=JoZ05goSoafYEgld487utucNSKs=; b=eKBqU2YAukF8Ync/vgNm RtgdRLQfRSc6sWUsam/9rtqgDKRoSWhS6/wU/pw+Mkmm4yhCNH61pzf3QIeMKfYJ vUh5ThtWfFwxXE13cj9uu2IQ1JQ//p+uinFd5+gknyr11UuCl7tJtmeAw96vNfW9 kTaahgqRrWGSaIB1z/iunNA= Received: (qmail 111169 invoked by alias); 13 Apr 2018 09:05:52 -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 111081 invoked by uid 89); 13 Apr 2018 09:05:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_HELO_FAIL autolearn=ham version=3.3.2 spammy=UD:n, an, *does*, delicate X-HELO: aserp2120.oracle.com Received: from aserp2120.oracle.com (HELO aserp2120.oracle.com) (141.146.126.78) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 13 Apr 2018 09:05:41 +0000 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w3D8uRnH013460; Fri, 13 Apr 2018 09:05:39 GMT Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2h6ny3r3cw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 13 Apr 2018 09:05:39 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w3D95cPR003677 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 13 Apr 2018 09:05:38 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w3D95bhs011579; Fri, 13 Apr 2018 09:05:37 GMT Received: from [192.168.1.4] (/87.20.211.154) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 13 Apr 2018 02:05:36 -0700 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] PR 85112 ("[8 Regression] ICE with invalid constexpr") Message-ID: <800d19a8-a85a-d35c-f97e-e5999bf99467@oracle.com> Date: Fri, 13 Apr 2018 11:05:34 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8861 signatures=668698 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1804130083 X-IsSubscribed: yes Hi, in this error-recovery regression, after a sensible error message issued by cxx_constant_init, store_init_value stores an error_mark_node as DECL_INITIAL of the VAR_DECL for 'j'. This error_mark_node reappears much later, to cause a crash during gimplification. As far as I know, the choice of storing error_mark_nodes too is the outcome of a rather delicate error-recovery strategy and I don't think we want to revisit it at this time, thus the remaining option is catching later the error_mark_node, at a "good" time. I note, in passing, that the do loop in gimplify_expr which uses the crashing STRIP_USELESS_TYPE_CONVERSION seems a bit lacking from the error-recovery point of view, because at each iteration it *does* cover for error_operand_p (save_expr) but only immediately after the call, when it's too late. All the above said, I believe that at least for the 8.1.0 needs we may want to catch the error_mark_node in cp_build_modify_expr, when we are handling the assignment 'a.n = j;': convert_for_assignment produces a NOP_EXPR from the VAR_DECL for 'j' which then cp_convert_and_check regenerates (deep in convert_to_integer_1 via maybe_fold_build1_loc) in the final bare-bone form, with the error_mark_node as the first operand. Passes testing on x86_64-linux. Thanks, Paolo. ///////////////////////// /cp 2018-04-13 Paolo Carlini PR c++/85112 * typeck.c (cp_build_modify_expr): Return error_mark_node upon an error_mark_node wrapped in a NOP_EXPR too. /testsuite 2018-04-13 Paolo Carlini PR c++/85112 * g++.dg/cpp0x/pr85112.C: New. Index: cp/typeck.c =================================================================== --- cp/typeck.c (revision 259359) +++ cp/typeck.c (working copy) @@ -8234,7 +8234,9 @@ cp_build_modify_expr (location_t loc, tree lhs, en TREE_OPERAND (newrhs, 0)); } - if (newrhs == error_mark_node) + if (newrhs == error_mark_node + || (TREE_CODE (newrhs) == NOP_EXPR + && TREE_OPERAND (newrhs, 0) == error_mark_node)) return error_mark_node; if (c_dialect_objc () && flag_objc_gc) Index: testsuite/g++.dg/cpp0x/pr85112.C =================================================================== --- testsuite/g++.dg/cpp0x/pr85112.C (nonexistent) +++ testsuite/g++.dg/cpp0x/pr85112.C (working copy) @@ -0,0 +1,17 @@ +// PR c++/85112 +// { dg-do compile { target c++11 } } + +struct A +{ + int m; + int n : 4; +}; + +int i; // { dg-message "not const" } + +void foo() +{ + constexpr int j = i; // { dg-error "not usable" } + A a; + a.n = j; +}