From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id D89EC3858C52; Fri, 23 Sep 2022 07:11:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D89EC3858C52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663917078; bh=J9vVXqB1Xn8pzwkasa+7c5NWJsC6pDJ41h/0Lq9Jxlw=; h=From:To:Subject:Date:From; b=FQ+PwOjwWwF9AuokdcT6H8CUCCX9iWj30RYkPjtfJeVdIABEO+4Ngd45HopYKzjMn 9EleYEUQgR3s4y3Aid9y3ZoOGDaITjWGgGOsgFcO1fNQjDvgLLkqfShviyarahekoR DTEPW/0mnZK+O7kvyUFi2qrB/qN4IzsnqVYnAcQ8= MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-2805] attribs: Improve diagnostics X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/master X-Git-Oldrev: a282f086ef26d90e9785e992cd09a0d118b24695 X-Git-Newrev: 2ec6489d7a595c78cae4584244afd4ca91d6c8ff Message-Id: <20220923071118.D89EC3858C52@sourceware.org> Date: Fri, 23 Sep 2022 07:11:18 +0000 (GMT) List-Id: https://gcc.gnu.org/g:2ec6489d7a595c78cae4584244afd4ca91d6c8ff commit r13-2805-g2ec6489d7a595c78cae4584244afd4ca91d6c8ff Author: Jakub Jelinek Date: Fri Sep 23 09:10:16 2022 +0200 attribs: Improve diagnostics 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 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. Diff: --- gcc/attribs.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gcc/attribs.cc b/gcc/attribs.cc index fb89616ff29..b1f103222aa 100644 --- a/gcc/attribs.cc +++ b/gcc/attribs.cc @@ -737,6 +737,9 @@ decl_attributes (tree *node, tree attributes, int flags, 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);