From patchwork Wed Nov 16 09:33:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Senthil Kumar Selvaraj X-Patchwork-Id: 695479 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 3tJfHZ2NvDz9t3N for ; Wed, 16 Nov 2016 20:35:06 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="tBajB4Ol"; 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:from :to:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=NJquHg7MlCf7R0DG1eJYUT6aEyFPauL98QgmCqlVL8OjdhL0Oenph ctVyC20cBkXwqM07TL6DnaRW5b4Au2V/SFxKjfrlXVMFQ1MNW2yUDQjWw/+b/WDk 2ZLJs9H9CnJ3kLTV++6Wrpmps/kGgPMw8Q1eoZnc6KQ3KLenWL4e34= 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:from :to:subject:date:message-id:mime-version:content-type; s= default; bh=SI6q/5nz5O6YgkM+y6cPYv2K0Vk=; b=tBajB4OlHxyPqB+kRAT+ kmli86qW4MvBFTD3WBJ4KWDOyna9RIRHjGK4ci69jjf1YKErwXMxzCHc5azzmPBq OMIgJ2aKUHCo5eHKG18FjZ60EjbK6aiI0BEIh9tme0WW6Sc3wP45cyZC7NDvkVKH y44EqRcuE+BHJrCvAfh93iI= Received: (qmail 13531 invoked by alias); 16 Nov 2016 09:34:56 -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 13258 invoked by uid 89); 16 Nov 2016 09:34:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.8 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=Stay, s.a, Sa, 2016-11-16 X-HELO: eusmtp01.atmel.com Received: from eusmtp01.atmel.com (HELO eusmtp01.atmel.com) (212.144.249.243) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 16 Nov 2016 09:34:44 +0000 Received: from HNOCHT01.corp.atmel.com (10.145.133.40) by eusmtp01.atmel.com (10.145.145.31) with Microsoft SMTP Server (TLS) id 14.3.235.1; Wed, 16 Nov 2016 10:34:35 +0100 Received: from jaguar.atmel.com (10.145.133.18) by HNOCHT01.corp.atmel.com (10.145.133.40) with Microsoft SMTP Server (TLS) id 14.3.235.1; Wed, 16 Nov 2016 10:34:38 +0100 User-agent: mu4e 0.9.17; emacs 24.5.1 From: Senthil Kumar Selvaraj To: GCC Patches Subject: [Patch, testsuite] Fix bogus Wlogical-op-1.c test failure for avr Date: Wed, 16 Nov 2016 15:03:13 +0530 Message-ID: <87bmxfahwm.fsf@atmel.com> MIME-Version: 1.0 X-IsSubscribed: yes Hi, The below patch fixes c-c++-common/Wlogical-op-1.c for avr by explicitly typedef'ing __INT32_TYPE for int and __INT16_TYPE__ for short if the target's int size is less than 4 bytes. The test assumes short is always smaller than int, and therefore does not expect a warning when the logical operands are of type short and int. This isn't true for the avr - shorts and ints are of the same size, and therefore the warning triggers for the above case also. Committed to trunk as obvious. Regards Senthil gcc/testsuite/ChangeLog 2016-11-16 Senthil Kumar Selvaraj * c-c++-common/Wlogical-op-1.c: Use __INT{16,32}_TYPE__ instead of {short,int} if __SIZEOF_INT__ is less than 4 bytes. Index: c-c++-common/Wlogical-op-1.c =================================================================== --- c-c++-common/Wlogical-op-1.c (revision 242471) +++ c-c++-common/Wlogical-op-1.c (working copy) @@ -8,12 +8,22 @@ # define false 0 #endif -extern int bar (void); -extern int *p; -struct R { int a, b; } S; +#if __SIZEOF_INT__ < 4 + __extension__ typedef __INT32_TYPE__ int32_t; + __extension__ typedef __UINT32_TYPE__ uint32_t; + __extension__ typedef __INT16_TYPE__ int16_t; +#else + typedef int int32_t; + typedef unsigned int uint32_t; + typedef short int16_t; +#endif +extern int32_t bar (void); +extern int32_t *p; +struct R { int32_t a, b; } S; + void -andfn (int a, int b) +andfn (int32_t a, int32_t b) { if (a && a) {} /* { dg-warning "logical .and. of equal expressions" } */ if (!a && !a) {} /* { dg-warning "logical .and. of equal expressions" } */ @@ -34,7 +44,7 @@ if (p[0] && p[0]) {} /* { dg-warning "logical .and. of equal expressions" } */ if (S.a && S.a) {} /* { dg-warning "logical .and. of equal expressions" } */ if ((bool) a && (bool) a) {} /* { dg-warning "logical .and. of equal expressions" } */ - if ((unsigned) a && a) {} /* { dg-warning "logical .and. of equal expressions" } */ + if ((uint32_t) a && a) {} /* { dg-warning "logical .and. of equal expressions" } */ /* Stay quiet here. */ if (a && b) {} @@ -48,7 +58,7 @@ if (a > 0 && a > 1) {} if (a > -2 && a > 1) {} - if (a && (short) a) {} + if (a && (int16_t) a) {} if ((char) a && a) {} if (++a && a) {} if (++a && ++a) {} @@ -61,7 +71,7 @@ } void -orfn (int a, int b) +orfn (int32_t a, int32_t b) { if (a || a) {} /* { dg-warning "logical .or. of equal expressions" } */ if (!a || !a) {} /* { dg-warning "logical .or. of equal expressions" } */ @@ -82,7 +92,7 @@ if (p[0] || p[0]) {} /* { dg-warning "logical .or. of equal expressions" } */ if (S.a || S.a) {} /* { dg-warning "logical .or. of equal expressions" } */ if ((bool) a || (bool) a) {} /* { dg-warning "logical .or. of equal expressions" } */ - if ((unsigned) a || a) {} /* { dg-warning "logical .or. of equal expressions" } */ + if ((uint32_t) a || a) {} /* { dg-warning "logical .or. of equal expressions" } */ /* Stay quiet here. */ if (a || b) {} @@ -96,7 +106,7 @@ if (a > 0 || a > 1) {} if (a > -2 || a > 1) {} - if (a || (short) a) {} + if (a || (int16_t) a) {} if ((char) a || a) {} if (++a || a) {} if (++a || ++a) {}