public inbox for
help / color / mirror / Atom feed
* [gcc r13-2805] attribs: Improve diagnostics
@ 2022-09-23  7:11 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2022-09-23  7:11 UTC (permalink / raw)
  To: gcc-cvs

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
    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  <>
            * (decl_attributes): Improve diagnostics, instead of
            saying expected between 1 and 1, found 2 just say expected 1, found 2.

 gcc/ | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gcc/ b/gcc/
index fb89616ff29..b1f103222aa 100644
--- a/gcc/
+++ b/gcc/
@@ -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);
 		inform (input_location, "expected between %i and %i, found %i",
 			spec->min_length, spec->max_length, nargs);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-09-23  7:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-23  7:11 [gcc r13-2805] attribs: Improve diagnostics Jakub Jelinek

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).