From patchwork Mon Jun 4 18:50:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 162853 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 F00DAB6F6E for ; Tue, 5 Jun 2012 04:52:24 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1339440745; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Message-ID:Date:From:User-Agent:MIME-Version: To:CC:Subject:References:In-Reply-To:Content-Type:Mailing-List: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:Sender:Delivered-To; bh=41FycxFqbcBu1/ScNt6ZdjLwp/M=; b=u7F2IjcN5ezAuKvMt7T0v83bBH4n5DBxPW2SrQ1wlkEFJJVOqJaSoIWHqsIrVt nfkH5MtqEA2Pcqxhx+cMrQJUZAm+ccd6dig4OfvPczezKnRxWru4exsbAoSVUFYU Yme7kim135xZ3HmkyeKfV5qyuZgaRXbdhJwVlWsWRmM2Y= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:References:In-Reply-To:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=mnCCHf+SgZFbhE3Yj1FEUanDiWyX7rWFkuuqp0ztxqKxHeNB3qkC1J5YgoF9JS q+80U/U6ibcqCQyCsetoGz92AWaff4EB6MWBA7QgsV1bULd1jwsDhDdD2P8+81wQ 135Aiauf7b8VgBysGAceNPkOvU5PuuBosyAguNz80JWzY=; Received: (qmail 25599 invoked by alias); 4 Jun 2012 18:52:16 -0000 Received: (qmail 25586 invoked by uid 22791); 4 Jun 2012 18:52:14 -0000 X-SWARE-Spam-Status: No, hits=-7.4 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_THREADED, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_NO, RCVD_IN_HOSTKARMA_W, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from acsinet15.oracle.com (HELO acsinet15.oracle.com) (141.146.126.227) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 04 Jun 2012 18:51:59 +0000 Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by acsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id q54IpuR8014207 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 4 Jun 2012 18:51:57 GMT Received: from acsmt356.oracle.com (acsmt356.oracle.com [141.146.40.156]) by ucsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id q54IpsTA011364 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 4 Jun 2012 18:51:55 GMT Received: from abhmt104.oracle.com (abhmt104.oracle.com [141.146.116.56]) by acsmt356.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id q54IpsJ1007668; Mon, 4 Jun 2012 13:51:54 -0500 Received: from [192.168.1.4] (/79.53.82.91) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 04 Jun 2012 11:51:54 -0700 Message-ID: <4FCD0372.4050003@oracle.com> Date: Mon, 04 Jun 2012 20:50:26 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120421 Thunderbird/12.0 MIME-Version: 1.0 To: Jason Merrill CC: "gcc-patches@gcc.gnu.org" Subject: Re: [C++ Patch] PR 53524 References: <4FC74B63.3020005@oracle.com> <4FC78389.9080809@redhat.com> <4FC7864C.9010206@oracle.com> <4FCCE87C.1070305@redhat.com> <4FCCF5C4.3020006@oracle.com> <4FCCFD56.3030900@redhat.com> In-Reply-To: <4FCCFD56.3030900@redhat.com> 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 On 06/04/2012 08:24 PM, Jason Merrill wrote: > On 06/04/2012 01:52 PM, Paolo Carlini wrote: >> Ok, this would be simple to do. The only issue I can see, is that in C++ >> -Wenum-compare has a name, thus can be easily disabled but it's ON by >> default. > The warning is already on by default, so that wouldn't be a change; > this just creates a way for users to turn it off until we deal with > the unhelpful case. Ok. The below passes the testsuite on x86_64-linux. Ok for mainline and 4.7.1? Thanks, Paolo. ///////////////////// 2012-06-04 Paolo Carlini PR c++/53524 * doc/invoke.texi (Wenum-compare): Update documentation. /cp 2012-06-04 Paolo Carlini PR c++/53524 * call.c (build_conditional_expr_1): Use OPT_Wenum_compare to control enumeral mismatch in conditional expression too. /testsuite 2012-06-04 Paolo Carlini PR c++/53524 * g++.dg/warn/Wenum-compare-no-2: New. Index: doc/invoke.texi =================================================================== --- doc/invoke.texi (revision 188196) +++ doc/invoke.texi (working copy) @@ -4297,9 +4297,10 @@ while} statement. This warning is also enabled by @item -Wenum-compare @opindex Wenum-compare @opindex Wno-enum-compare -Warn about a comparison between values of different enumerated types. In C++ -this warning is enabled by default. In C this warning is enabled by -@option{-Wall}. +Warn about a comparison between values of different enumerated types. +In C++ enumeral mismatches in conditional expressions are also +diagnosed and the warning is enabled by default. In C this warning is +enabled by @option{-Wall}. @item -Wjump-misses-init @r{(C, Objective-C only)} @opindex Wjump-misses-init Index: testsuite/g++.dg/warn/Wenum-compare-no-2.C =================================================================== --- testsuite/g++.dg/warn/Wenum-compare-no-2.C (revision 0) +++ testsuite/g++.dg/warn/Wenum-compare-no-2.C (revision 0) @@ -0,0 +1,31 @@ +// PR c++/53524 +// { dg-options "-Wno-enum-compare" } + +template < typename > struct PointerLikeTypeTraits { + enum { NumLowBitsAvailable }; +}; + +class CodeGenInstruction; +class CodeGenInstAlias; + +template < typename T> +struct PointerIntPair { + enum { IntShift = T::NumLowBitsAvailable }; +}; + +template < typename PT1, typename PT2 > struct PointerUnionUIntTraits { + enum { + PT1BitsAv = PointerLikeTypeTraits < PT1 >::NumLowBitsAvailable, + PT2BitsAv = PointerLikeTypeTraits < PT2 >::NumLowBitsAvailable, + NumLowBitsAvailable = 0 ? PT1BitsAv : PT2BitsAv + }; +}; + +template < typename PT1, typename PT2 > class PointerUnion { + typedef PointerIntPair < PointerUnionUIntTraits < PT1, PT2 > > ValTy; + ValTy Val; +}; + +struct ClassInfo { + PointerUnion < CodeGenInstruction *, CodeGenInstAlias * > DefRec; +}; Index: testsuite/g++.dg/cpp0x/alias-decl-19.C =================================================================== Index: cp/call.c =================================================================== --- cp/call.c (revision 188196) +++ cp/call.c (working copy) @@ -4696,7 +4696,7 @@ build_conditional_expr_1 (tree arg1, tree arg2, tr && TREE_CODE (arg3_type) == ENUMERAL_TYPE) { if (complain & tf_warning) - warning (0, + warning (OPT_Wenum_compare, "enumeral mismatch in conditional expression: %qT vs %qT", arg2_type, arg3_type); }