From patchwork Mon Jun 20 22:58:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 638332 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3rYRBC4sr9z9t0M for ; Tue, 21 Jun 2016 08:59:14 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=s2i6evzB; dkim-atps=neutral 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=j3SAJ/yq6f3zLRdcptwJmYWLmKBPGC+5KTyi0T5thlaTqygN++80P n7RHaOsQ865+1kICaB3nNQv04IXMSXDJL9EoGQ5I+NGnLG8CxpoFeRuVew52tTne U4lwIpnAfisK0K1r6+3UCmEml/YQ43dnHHhEQ9Qa0WAGd6c4zJxuTg= 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=lNBKFT3OTz4uTIx3gWP4ouN7jR0=; b=s2i6evzBtrurbu0Sw66j tIsVeXio1JdOqe3RPYnRlDa1/Kd6J5fB0d9vwzMciM+m50B6ThIy/lnwZAROkok4 IKslRuBD1McCd2Hfc+8BzSr2ZeTxW+J3WmWYe9WDBJusZoBWsoHN33qlOR/j06rB HdnYsdX0w1HtdffT+5UEtDI= Received: (qmail 111726 invoked by alias); 20 Jun 2016 22:59:02 -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 111695 invoked by uid 89); 20 Jun 2016 22:59:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL, BAYES_00, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=no version=3.3.2 spammy=type2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 20 Jun 2016 22:58:47 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1bF89T-00063f-Rq from joseph_myers@mentor.com for gcc-patches@gcc.gnu.org; Mon, 20 Jun 2016 15:58:44 -0700 Received: from digraph.polyomino.org.uk (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.3.224.2; Mon, 20 Jun 2016 23:58:42 +0100 Received: from jsm28 (helo=localhost) by digraph.polyomino.org.uk with local-esmtp (Exim 4.86_2) (envelope-from ) id 1bF89R-0004cm-7O for gcc-patches@gcc.gnu.org; Mon, 20 Jun 2016 22:58:41 +0000 Date: Mon, 20 Jun 2016 22:58:41 +0000 From: Joseph Myers To: Subject: Fix ICE on conditional expression between DFP and non-DFP float (PR c/71601) Message-ID: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 A conditional expression between DFP and non-DFP floating-point produces an ICE. This patch fixes this by making build_conditional_expr return early when c_common_type produces an error. Bootstrapped with no regressions on x86_64-pc-linux-gnu. Applied to mainline. gcc/c: 2016-06-20 Joseph Myers PR c/71601 * c-typeck.c (build_conditional_expr): Return error_mark_node if c_common_type returns error_mark_node. gcc/testsuite: 2016-06-20 Joseph Myers PR c/71601 * gcc.dg/dfp/usual-arith-conv-bad-3.c: New test. Index: gcc/c/c-typeck.c =================================================================== --- gcc/c/c-typeck.c (revision 237589) +++ gcc/c/c-typeck.c (working copy) @@ -4846,6 +4846,8 @@ build_conditional_expr (location_t colon_loc, tree || code2 == COMPLEX_TYPE)) { result_type = c_common_type (type1, type2); + if (result_type == error_mark_node) + return error_mark_node; do_warn_double_promotion (result_type, type1, type2, "implicit conversion from %qT to %qT to " "match other result of conditional", Index: gcc/testsuite/gcc.dg/dfp/usual-arith-conv-bad-3.c =================================================================== --- gcc/testsuite/gcc.dg/dfp/usual-arith-conv-bad-3.c (nonexistent) +++ gcc/testsuite/gcc.dg/dfp/usual-arith-conv-bad-3.c (working copy) @@ -0,0 +1,13 @@ +/* Test error for conditional expression between DFP and other + floating operand. */ +/* { dg-do compile } */ + +_Decimal32 a; +float b; +int i; + +void +f (void) +{ + (void) (i ? a : b); /* { dg-error "mix operands" } */ +}