From patchwork Tue Aug 28 12:43:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 962905 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-484591-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="pPUQok/a"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="2BcBzycI"; 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 4207k2387hz9s1c for ; Tue, 28 Aug 2018 22:44:25 +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=pzjtmf8pAltrj1KdqkPE+cycJCvPlicvmv8ZHq9LmqoLwgombA aL7XvASf+OQasirtJ2bMhPgqtSdE6SLYCa9aVQs3s4Xua8cnNcpmbeG356YTJu4o B2FswIUJ0Bo/KNbh3SLpfS28tIUfYQ2W6RD5tk3XRfDublclLekdfS2U4= 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=SGhZHPnFW44AIpLfMMaxvPPnqB4=; b=pPUQok/aU3pLzQpDYNTq oCpS294sbP7bYcpdHnNu26aCbcEbLznemd0AUlSePjAfRRAjSC5hmSkXbzjmHyN3 /wvsSOF08CNjUpMh+De+qk5vSQ5wyTKKXd/qDTe3epBhf87s2QbtV9zwZWpL5XD6 508totGikxXYQzEUIhDCTLo= Received: (qmail 44193 invoked by alias); 28 Aug 2018 12:44:18 -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 44154 invoked by uid 89); 28 Aug 2018 12:44:14 -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=H*r:ip*192.168.1.4, H*RU:192.168.1.4, Hx-spam-relays-external:192.168.1.4, Hx-languages-length:1758 X-HELO: userp2130.oracle.com Received: from userp2130.oracle.com (HELO userp2130.oracle.com) (156.151.31.86) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 28 Aug 2018 12:44:12 +0000 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w7SCd9KH125534; Tue, 28 Aug 2018 12:43:59 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=O48br+WrLMbwnCfJQ5OTUgNSsGhs0uaH4+jUAm6JvWY=; b=2BcBzycISzluV1Q00WqUvx/rKKdWcxXOSvr3abvcOyq653ELyjWk3oiMkEO6ard/WQwc D6J6oqqDpx3odAOV3CbfNCoaGGdwV4qfwGEBgm1Ib4e+pAVwQ4Z6IvCtTHTG8gOC0qH7 UE44ZLaDLRG6uVMdbcTCWRI6RyIt4ll+ObU7b6ubhAjc7OkRqj+Mes6kG48AsZsOH8gD g00XO5yurR9eWCc+y+MER4QnHOvqoQnif15ENqwOCyeHqtr26LsWJ1UtM0L+kTJQsBsb cRfXK8fyEhGtL2dbkk8uLhpQqX3du36rqJURLZzjWH6xe5kLMejUOmSbRNVSeLyGL+D3 jQ== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2m2xhtkkxn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 28 Aug 2018 12:43:59 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w7SChwYC021252 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 28 Aug 2018 12:43:59 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w7SChw42000883; Tue, 28 Aug 2018 12:43:58 GMT Received: from [192.168.1.4] (/79.53.213.242) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 28 Aug 2018 05:43:57 -0700 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill , Nathan Sidwell From: Paolo Carlini Subject: [C++ Patch] PR 86546 (" ICE on invalid: tree_class_check_failed()") Message-ID: <68d72058-5ecc-ec06-f5a4-4578592ac905@oracle.com> Date: Tue, 28 Aug 2018 14:43:54 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 X-IsSubscribed: yes Hi, this low priority ICE on invalid happens only in c++98 mode but I think we can as well avoid it and have consistent error recovery across std modes. Essentially, the VAR_DECL for 'b' with erroneous TREE_TYPE (the type is incomplete) reaches cxx_eval_constant_expression and we ICE when we use COMPLETE_TYPE_P on the TREE_TYPE itself. I think we can - consistently across std modes - catch the erroneous type quite a bit earlier, midway in finish_case_label, thus before the case_conversion call which eventually leads to the ICE. Tested x86_64-linux. Thanks, Paolo. ///////////////////// /cp 2018-08-28 Paolo Carlini PR c++/86546 * decl.c (finish_case_label): If the type is erroneous early return error_mark_node. /testsuite 2018-08-28 Paolo Carlini PR c++/86546 * g++.dg/other/switch4.C: New. Index: cp/decl.c =================================================================== --- cp/decl.c (revision 263914) +++ cp/decl.c (working copy) @@ -3662,6 +3662,8 @@ finish_case_label (location_t loc, tree low_value, return error_mark_node; type = SWITCH_STMT_TYPE (switch_stack->switch_stmt); + if (type == error_mark_node) + return error_mark_node; low_value = case_conversion (type, low_value); high_value = case_conversion (type, high_value); Index: testsuite/g++.dg/other/switch4.C =================================================================== --- testsuite/g++.dg/other/switch4.C (nonexistent) +++ testsuite/g++.dg/other/switch4.C (working copy) @@ -0,0 +1,6 @@ +// PR c++/86546 + +class a b; // { dg-error "aggregate" } +void c() { + switch () // { dg-error "expected" } + case b // { dg-error "expected" }