Message ID | Yy1Sjn8VA1HVBkB7@tucnak |
---|---|
State | Committed |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1D5823858022 for <patchwork@sourceware.org>; Fri, 23 Sep 2022 06:31:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1D5823858022 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663914679; bh=p9RIM4Le8w8ze2jhgRS3R/u17FWMXji+Z/3tOLQZnRo=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=Qcnf0yO53363xAFwmBkchwogWZaFvSMz7089us8Os8Cij9p7JDgETZVgKIaRukqZo C5g1UxAExBATsVaCAAIqvff+2ED5dG0y2AUBrlU/byDLlznlD0sZ0PDBWKvYNACE7U MENE5dnsSQY/KZ+HRjhszQUx418GPOzaLqfQJtVs= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id D2A913858C52 for <gcc-patches@gcc.gnu.org>; Fri, 23 Sep 2022 06:30:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D2A913858C52 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-642-PfmhqZ7APYmskK6w8d7vUg-1; Fri, 23 Sep 2022 02:30:44 -0400 X-MC-Unique: PfmhqZ7APYmskK6w8d7vUg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 561BA185A792; Fri, 23 Sep 2022 06:30:44 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.194]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 05EF240C2064; Fri, 23 Sep 2022 06:30:43 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 28N6UdNK184040 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 23 Sep 2022 08:30:40 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 28N6UcCO184039; Fri, 23 Sep 2022 08:30:38 +0200 Date: Fri, 23 Sep 2022 08:30:38 +0200 To: Richard Biener <rguenther@suse.de> Subject: [PATCH] attribs: Improve diagnostics Message-ID: <Yy1Sjn8VA1HVBkB7@tucnak> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Jakub Jelinek via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Jakub Jelinek <jakub@redhat.com> Cc: gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
attribs: Improve diagnostics
|
|
Commit Message
Jakub Jelinek
Sept. 23, 2022, 6:30 a.m. UTC
Hi! When looking at the attribs code, I've noticed weird diagnostics like int a __attribute__((section ("foo", "bar"))); a.c:1:1: error: wrong number of arguments specified for ‘section’ attribute 1 | int a __attribute__((section ("foo", "bar"))); | ^~~ a.c:1:1: note: expected between 1 and 1, found 2 As roughly 50% of attributes that accept any arguments have spec->min_length == spec->max_length, I think it is worth it to have separate wording for such common case and just write simpler a.c:1:1: note: expected 1, found 2 Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2022-09-23 Jakub Jelinek <jakub@redhat.com> * attribs.cc (decl_attributes): Improve diagnostics, instead of saying expected between 1 and 1, found 2 just say expected 1, found 2. Jakub
Comments
On Fri, 23 Sep 2022, Jakub Jelinek wrote: > Hi! > > When looking at the attribs code, I've noticed weird diagnostics > like > int a __attribute__((section ("foo", "bar"))); > a.c:1:1: error: wrong number of arguments specified for ?section? attribute > 1 | int a __attribute__((section ("foo", "bar"))); > | ^~~ > a.c:1:1: note: expected between 1 and 1, found 2 > As roughly 50% of attributes that accept any arguments have > spec->min_length == spec->max_length, I think it is worth it to have > separate wording for such common case and just write simpler > a.c:1:1: note: expected 1, found 2 > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? OK. Thanks, Richard. > 2022-09-23 Jakub Jelinek <jakub@redhat.com> > > * attribs.cc (decl_attributes): Improve diagnostics, instead of > saying expected between 1 and 1, found 2 just say expected 1, found 2. > > --- gcc/attribs.cc.jj 2022-09-22 10:54:44.693705319 +0200 > +++ gcc/attribs.cc 2022-09-22 18:18:38.142414100 +0200 > @@ -737,6 +737,9 @@ decl_attributes (tree *node, tree attrib > if (spec->max_length < 0) > inform (input_location, "expected %i or more, found %i", > spec->min_length, nargs); > + else if (spec->min_length == spec->max_length) > + inform (input_location, "expected %i, found %i", > + spec->min_length, nargs); > else > inform (input_location, "expected between %i and %i, found %i", > spec->min_length, spec->max_length, nargs); > > > Jakub > >
--- gcc/attribs.cc.jj 2022-09-22 10:54:44.693705319 +0200 +++ gcc/attribs.cc 2022-09-22 18:18:38.142414100 +0200 @@ -737,6 +737,9 @@ decl_attributes (tree *node, tree attrib if (spec->max_length < 0) inform (input_location, "expected %i or more, found %i", spec->min_length, nargs); + else if (spec->min_length == spec->max_length) + inform (input_location, "expected %i, found %i", + spec->min_length, nargs); else inform (input_location, "expected between %i and %i, found %i", spec->min_length, spec->max_length, nargs);