From: Jakub Jelinek Date: Fri, 23 Sep 2022 07:10:16 +0000 (+0200) Subject: attribs: Improve diagnostics X-Git-Tag: basepoints/gcc-14~4402 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2ec6489d7a595c78cae4584244afd4ca91d6c8ff;p=thirdparty%2Fgcc.git 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 --git a/gcc/attribs.cc b/gcc/attribs.cc index fb89616ff296..b1f103222aac 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);