From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 6F2713858C52 for ; Fri, 23 Sep 2022 06:49:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6F2713858C52 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 35464219C9; Fri, 23 Sep 2022 06:49:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1663915790; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=OEuCDu42QFILpWaLDXadgpixuG97X+1hvk48rWu331o=; b=SBS9C2E2AFfzvn3x4EbvvWJBwh3MCrv3KpTY63jL2S48mdBO14QlUhlBqPNiypDj/SBk58 lBT1hDStTI480Yygy6g1peQqJ5HBFhlbqQmq+H1Uzgke5EYa9Fj0hgAsc6AqFuEs3cYdHB QGE/RlgdOImzfqlAbbzx4LROahpcpBg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1663915790; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=OEuCDu42QFILpWaLDXadgpixuG97X+1hvk48rWu331o=; b=tgwO20NyvlcMkm3N+2GOJyA2nSkcwiHaAhwUrYahIQHFe/G5MaxGOHlqPUO27pMomeiWbb P+9ub1QDP1YQ/8CA== Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 2E7852C14F; Fri, 23 Sep 2022 06:49:50 +0000 (UTC) Date: Fri, 23 Sep 2022 06:49:50 +0000 (UTC) From: Richard Biener To: Jakub Jelinek cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] attribs: Improve diagnostics In-Reply-To: Message-ID: References: User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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 List-Id: On Fri, 23 Sep 2022, Jakub Jelinek wrote: > 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? OK. Thanks, Richard. > 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. > > --- 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); > > > Jakub > > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman; HRB 36809 (AG Nuernberg)