public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-2805] attribs: Improve diagnostics
Date: Fri, 23 Sep 2022 07:11:18 +0000 (GMT) [thread overview]
Message-ID: <20220923071118.D89EC3858C52@sourceware.org> (raw)
https://gcc.gnu.org/g:2ec6489d7a595c78cae4584244afd4ca91d6c8ff
commit r13-2805-g2ec6489d7a595c78cae4584244afd4ca91d6c8ff
Author: Jakub Jelinek <jakub@redhat.com>
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 <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.
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);
reply other threads:[~2022-09-23 7:11 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220923071118.D89EC3858C52@sourceware.org \
--to=jakub@gcc.gnu.org \
--cc=gcc-cvs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).