From patchwork Fri Sep 23 06:30:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1399 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp71529wrt; Thu, 22 Sep 2022 23:31:34 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4qR7sJu5kHJbkSRlDq9P3ACdugpyVXh5rfTXB+o1JaoTQYC7WOuV38kJa/UHzKQaydFW+p X-Received: by 2002:a05:6402:3211:b0:453:ba03:9dee with SMTP id g17-20020a056402321100b00453ba039deemr6928494eda.351.1663914694287; Thu, 22 Sep 2022 23:31:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663914694; cv=none; d=google.com; s=arc-20160816; b=EiiqSjM76tYSbTyoK4LYb5gW6ZckFL3lwi91LPhAOqMH2p9GOSyXiCmvjb6NmUfEEf hIqNZsIq5Vx7KdvTJKZL24Lobbw+Awv+730Tt0qibYroyDyDfk20gFuZpLhjeZBAZ44I v5NqscQQhDXCe+/NaipHWWD+7U1i5oRyk5DswwY0PkYhqvMkP/FD3mVA/TlWpelN3H6O jZVrGlQuz5LShiXKBDQ+WhgBPkDu/mhVv9SdiC9htDjdu3eTdh9xyxGgLDwEYlmEiyi5 FiwLHCz1CNyYY/OSroWHjteBk8z8CuY2GNFT4afjzOrkcrY2dUvEOzRQF0rZwWDdWxt2 zhpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:content-disposition:mime-version :message-id:subject:to:date:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=p9RIM4Le8w8ze2jhgRS3R/u17FWMXji+Z/3tOLQZnRo=; b=HY5+OuFR+AcxxC5YAn0QvngW3tHTKYvKdREwbhfTSTAsHZnMOlVKvD1d233u4/1s7h 0+E+A4VntwPgE5N72q72K1R8esXnsu7KXMd4h+JR7H2FLSemmZVeOIIHQoNWtHSN2Sb9 fF3E/8+GnpVk3keV9f/iHLr6ia8rKJlxSzcvzPjVNOnmEVisD3SjrJ2dpTlmJKkqFNcp LQikRRWUkedD8unsB+eUFEs9yK3HYTklwSnZAz1sxLDPFFZTcBRVN1KHQy9qTOUB2X1a +ahRRXNrR0w/o45NER589E4mBa7WbsLDfwfkf3rPjQA2go3YLBCexP6aMiXcpU/Iekku mIyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=beMZt6lQ; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id ht13-20020a170907608d00b007807f3d1e6dsi7597560ejc.599.2022.09.22.23.31.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Sep 2022 23:31:34 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=beMZt6lQ; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2E1E23857C4E for ; Fri, 23 Sep 2022 06:31:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2E1E23857C4E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663914693; 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=beMZt6lQg0vzAj0S99a5qPKw/dc5A7o6OQXgY1EkGz4V/qun4K+6G/jKFRS54zw0d whVvk7RcChTPei7ZZ9+Wtq0/4kjlSE3YNOnC9wFq+tIqF7v1YF6DqFjAlMq8YpSZ9u gJyxu/wY41DPolvwoHa22GwiqT/4EPtArNnIs1qU= 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 ; 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 Subject: [PATCH] attribs: Improve diagnostics Message-ID: 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-Disposition: inline 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1744741014647068749?= X-GMAIL-MSGID: =?utf-8?q?1744741014647068749?= 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 * attribs.cc (decl_attributes): Improve diagnostics, instead of saying expected between 1 and 1, found 2 just say expected 1, found 2. 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);