From patchwork Wed Jan 19 02:50:55 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nicola Pero X-Patchwork-Id: 79394 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]) by ozlabs.org (Postfix) with SMTP id BF00BB70A9 for ; Wed, 19 Jan 2011 13:51:08 +1100 (EST) Received: (qmail 12186 invoked by alias); 19 Jan 2011 02:51:06 -0000 Received: (qmail 12176 invoked by uid 22791); 19 Jan 2011 02:51:04 -0000 X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from fencepost.gnu.org (HELO fencepost.gnu.org) (140.186.70.10) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 19 Jan 2011 02:51:00 +0000 Received: from eggs.gnu.org ([140.186.70.92]:45289) by fencepost.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1PfO8M-00014Z-Ps for gcc-patches@gnu.org; Tue, 18 Jan 2011 21:50:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PfO8O-0006JW-Lx for gcc-patches@gnu.org; Tue, 18 Jan 2011 21:50:57 -0500 Received: from smtp161.iad.emailsrvr.com ([207.97.245.161]:42200) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PfO8O-0006JQ-Jj for gcc-patches@gnu.org; Tue, 18 Jan 2011 21:50:56 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp46.relay.iad1a.emailsrvr.com (SMTP Server) with ESMTP id DF7D9E8949 for ; Tue, 18 Jan 2011 21:50:55 -0500 (EST) Received: from dynamic9.wm-web.iad.mlsrvr.com (dynamic9.wm-web.iad1a.rsapps.net [192.168.2.216]) by smtp46.relay.iad1a.emailsrvr.com (SMTP Server) with ESMTP id CE7E4E842A for ; Tue, 18 Jan 2011 21:50:55 -0500 (EST) Received: from meta-innovation.com (localhost [127.0.0.1]) by dynamic9.wm-web.iad.mlsrvr.com (Postfix) with ESMTP id B87BD320088 for ; Tue, 18 Jan 2011 21:50:55 -0500 (EST) Received: by www2.webmail.us (Authenticated sender: nicola.pero@meta-innovation.com, from: nicola.pero@meta-innovation.com) with HTTP; Wed, 19 Jan 2011 03:50:55 +0100 (CET) Date: Wed, 19 Jan 2011 03:50:55 +0100 (CET) Subject: Fix for PR c/43082 From: "Nicola Pero" To: "gcc-patches@gnu.org" MIME-Version: 1.0 X-Type: plain Message-ID: <1295405455.754426125@192.168.4.58> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-IsSubscribed: yes 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 This patch fixes PR c/43082 ("[4.3/4.4/4.5/4.6 Regression] ICE in tree check: expected class 'type', have 'exceptional' (error_mark) in useless_type_conversion_p"). Andrew Pinski had already produced a reduced testcase, and a working patch -- http://gcc.gnu.org/ml/gcc-patches/2010-03/msg00198.html the patch was good, but it didn't get applied as Joseph recommended a different approach (I guess Andrew didn't have time to follow up ?). Here is a new patch that uses Joseph's recommended approach. Bootstrapped and tested on i686-pc-linux-gnu. Ok to commit to trunk (4.6) ? Thanks PS: C++ does not have this problem and does not seem to need fixing; it produces the error test.cc:4:32: error: could not convert ‘0’ to ‘bool’ without ICEing. Index: ChangeLog =================================================================== --- ChangeLog (revision 168968) +++ ChangeLog (working copy) @@ -1,3 +1,10 @@ +2011-01-19 Nicola Pero + + PR c/43082 + * c-typeck.c (c_objc_common_truthvalue_conversion): If we are + passed a VOID_TYPE expression, immediately emit an error and + return error_mark_node. + 2011-01-18 Eric Botcazou PR middle-end/46894 Index: testsuite/gcc.dg/pr43082.c =================================================================== --- testsuite/gcc.dg/pr43082.c (revision 0) +++ testsuite/gcc.dg/pr43082.c (revision 0) @@ -0,0 +1,10 @@ +/* Test that the compiler does not crash when void expressions are + found inside conditional expressions. PR c/43082. */ +/* { dg-do compile } */ + +void +foo (int x) +{ + if (x ? (void)(0) : (void)(1)) /* { dg-error "void value not ignored as it ought to be" } */ + ; +} Index: testsuite/ChangeLog =================================================================== --- testsuite/ChangeLog (revision 168968) +++ testsuite/ChangeLog (working copy) @@ -1,3 +1,9 @@ +2011-01-18 Nicola Pero + Andrew Pinski + + PR c/43082 + * gcc.dg/pr43082.c: New. + 2011-01-18 Dominique d'Humieres PR testsuite/41146 Index: c-typeck.c =================================================================== --- c-typeck.c (revision 168968) +++ c-typeck.c (working copy) @@ -10270,6 +10270,10 @@ c_objc_common_truthvalue_conversion (location_t lo error_at (location, "used union type value where scalar is required"); return error_mark_node; + case VOID_TYPE: + error_at (location, "void value not ignored as it ought to be"); + return error_mark_node; + case FUNCTION_TYPE: gcc_unreachable (); @@ -10282,8 +10286,8 @@ c_objc_common_truthvalue_conversion (location_t lo if (int_operands) expr = remove_c_maybe_const_expr (expr); - /* ??? Should we also give an error for void and vectors rather than - leaving those to give errors later? */ + /* ??? Should we also give an error for vectors rather than leaving + those to give errors later? */ expr = c_common_truthvalue_conversion (location, expr); if (TREE_CODE (expr) == INTEGER_CST && int_operands && !int_const)