From patchwork Wed Aug 24 10:18:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 662188 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 3sK3DW4V5zz9sCy for ; Wed, 24 Aug 2016 20:18:33 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=WoURzuZV; 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=p680B3kp3klPn+6pC/1vngoW77XppOUQSAX5hVfjWePngwJo5108e CUROy0a6lQ600y1Ot6CDIw/q2gGIXPTwpt1byzBhkqBTiQ/tZb21tgVUDiTprZx9 ak0qcEeqgnp8qYwwBmLpkQ+Vj7JXdcBS4wA4FSteK67Rm+ev5t3t6s= 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=tP+PB9LBDlAxCO2QH+kHhyRLDPA=; b=WoURzuZVs/MoRBHRMZuJ He3MMvUJhM8Q17KGBgY/qHy8bBVvEBrFL49bsoRK1zC/15BUhQDn0ZHQzRAMM/oF qrsOmhHtD8x3QSnEFJd+x6KGSfzVT2mmKAstR0kyLejeJPQmmAIZhmQ+EMSgaagP G8r0oGPYN/8ZEy71e6w/+CM= Received: (qmail 122004 invoked by alias); 24 Aug 2016 10:18:25 -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 121969 invoked by uid 89); 24 Aug 2016 10:18:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=bitsize, specifiers, __int, int_n_enabled_p X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 24 Aug 2016 10:18:23 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 36A9C4E4D1; Wed, 24 Aug 2016 10:18:21 +0000 (UTC) Received: from redhat.com (ovpn-204-109.brq.redhat.com [10.40.204.109]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u7OAIHlA016108 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 24 Aug 2016 06:18:20 -0400 Date: Wed, 24 Aug 2016 12:18:17 +0200 From: Marek Polacek To: GCC Patches , Joseph Myers Subject: C PATCH to suppress a bogus "defaulting to int" warning (PR c/77323) Message-ID: <20160824101817.GD11131@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.6.2 (2016-07-01) When declaring something using an unsupported type specifier, such as __int128 on 32-bit systems, or _Float128x, the error for the unsupported type is followed by a warning about the type defaulting to int. But for unsupported types this warning isn't useful. The problem was that for these unsupported types typespec_word was set to cts_none, so in finish_declspecs we'd set default_int_p and thus warn in grokdeclarator. How to fix this became clear when I looked at how we handle fixed-point types and decimal floating point types -- by setting typespec_word even when we've given an error. The finish_declspecs hunk is needed so that we don't pass a null type to grokdeclarator. Tested also with make check-c RUNTESTFLAGS='dg.exp=pr77323.c --target_board=unix\{-m32,-m64\}' Bootstrapped/regtested on x86_64-linux, ok for trunk? 2016-08-24 Marek Polacek PR c/77323 * c-decl.c (declspecs_add_type): Set typespec_word even when __intN or _FloatN or _FloatNx is not supported. (finish_declspecs): Set type to integer_type_node when _FloatN or _FloatNx is not supported. * gcc.dg/pr77323.c: New test. Marek diff --git gcc/c/c-decl.c gcc/c/c-decl.c index 0fb2d20..0c52a64 100644 --- gcc/c/c-decl.c +++ gcc/c/c-decl.c @@ -10190,10 +10190,13 @@ declspecs_add_type (location_t loc, struct c_declspecs *specs, ("both %<__int%d%> and % in " "declaration specifiers"), int_n_data[specs->int_n_idx].bitsize); - else if (! int_n_enabled_p [specs->int_n_idx]) - error_at (loc, - "%<__int%d%> is not supported on this target", - int_n_data[specs->int_n_idx].bitsize); + else if (! int_n_enabled_p[specs->int_n_idx]) + { + specs->typespec_word = cts_int_n; + error_at (loc, + "%<__int%d%> is not supported on this target", + int_n_data[specs->int_n_idx].bitsize); + } else { specs->typespec_word = cts_int_n; @@ -10400,12 +10403,15 @@ declspecs_add_type (location_t loc, struct c_declspecs *specs, ? "x" : "")); else if (FLOATN_NX_TYPE_NODE (specs->floatn_nx_idx) == NULL_TREE) - error_at (loc, - "%<_Float%d%s%> is not supported on this target", - floatn_nx_types[specs->floatn_nx_idx].n, - (floatn_nx_types[specs->floatn_nx_idx].extended - ? "x" - : "")); + { + specs->typespec_word = cts_floatn_nx; + error_at (loc, + "%<_Float%d%s%> is not supported on this target", + floatn_nx_types[specs->floatn_nx_idx].n, + (floatn_nx_types[specs->floatn_nx_idx].extended + ? "x" + : "")); + } else { specs->typespec_word = cts_floatn_nx; @@ -10892,9 +10898,12 @@ finish_declspecs (struct c_declspecs *specs) case cts_floatn_nx: gcc_assert (!specs->long_p && !specs->short_p && !specs->signed_p && !specs->unsigned_p); - specs->type = (specs->complex_p - ? COMPLEX_FLOATN_NX_TYPE_NODE (specs->floatn_nx_idx) - : FLOATN_NX_TYPE_NODE (specs->floatn_nx_idx)); + if (FLOATN_NX_TYPE_NODE (specs->floatn_nx_idx) == NULL_TREE) + specs->type = integer_type_node; + else if (specs->complex_p) + specs->type = COMPLEX_FLOATN_NX_TYPE_NODE (specs->floatn_nx_idx); + else + specs->type = FLOATN_NX_TYPE_NODE (specs->floatn_nx_idx); break; case cts_dfloat32: case cts_dfloat64: diff --git gcc/testsuite/gcc.dg/pr77323.c gcc/testsuite/gcc.dg/pr77323.c index e69de29..281c334 100644 --- gcc/testsuite/gcc.dg/pr77323.c +++ gcc/testsuite/gcc.dg/pr77323.c @@ -0,0 +1,6 @@ +/* PR c/77323 */ +/* { dg-do compile { target ia32 } } */ +/* { dg-options "" } */ + +__int128 a; /* { dg-error "not supported" } */ +_Float128x b; /* { dg-error "not supported" } */