From: Georg-Johann Lay <avr@gjlay.de>
To: Jan-Benedict Glaw <jbglaw@lug-owl.de>
Cc: gcc-patches@gcc.gnu.org, Denis Chertykov <chertykov@gmail.com>
Subject: Re: [patch,avr,applied] PR target/112952 Fix attribute "io" et al. handling.
Date: Fri, 12 Jan 2024 13:32:26 +0100 [thread overview]
Message-ID: <bbba4fbf-d194-49e6-9460-d7c847d5d2c6@gjlay.de> (raw)
In-Reply-To: <20240112033702.GD2971@lug-owl.de>
Am 12.01.24 um 04:37 schrieb Jan-Benedict Glaw:
> On Thu, 2024-01-04 17:28:02 +0100, Georg-Johann Lay <avr@gjlay.de> wrote:
>> This fixes the avr-specific attributes io, io_low and address,
>> that are all basically the same except that io and io_low imply
>> assertions on allowed addressing modes.
>
>> --- a/gcc/config/avr/avr.cc
>> +++ b/gcc/config/avr/avr.cc
> [...]
>> @@ -10385,12 +10389,10 @@ avr_handle_addr_attribute (tree *node, tree name, tree args,
>> }
>> else if (io_p
>> && (!tree_fits_shwi_p (arg)
>> - || !(strcmp (IDENTIFIER_POINTER (name), "io_low") == 0
>> - ? low_io_address_operand : io_address_operand)
>> - (GEN_INT (TREE_INT_CST_LOW (arg)), QImode)))
>> + || ! IN_RANGE (TREE_INT_CST_LOW (arg), io_start, io_end)))
>> {
>> - warning_at (loc, OPT_Wattributes, "%qE attribute address "
>> - "out of range", name);
>> + warning_at (loc, OPT_Wattributes, "%qE attribute address out of "
>> + "range 0x%x...0x%x", name, (int) io_start, (int) io_end);
>> *no_add = true;
>> }
>> else
>
> Building with a recent GCC, this results in a new warning (here forced
> to an error with --enable-werror-alway--enable-werror-always):
>
> /var/lib/laminar/run/gcc-avr-elf/64/local-toolchain-install/bin/g++ -fno-PIE -c -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Wconditionally-supported -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror -fno-common -DHAVE_CONFIG_H -fno-PIE -I. -I. -I../../gcc/gcc -I../../gcc/gcc/. -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include -I../../gcc/gcc/../libcody -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/dpd -I../libdecnumber -I../../gcc/gcc/../libbacktrace -o avr.o -MT avr.o -MMD -MP -MF ./.deps/avr.TPo ../../gcc/gcc/config/avr/avr.cc
> ../../gcc/gcc/config/avr/avr.cc: In function 'tree_node* avr_handle_addr_attribute(tree_node**, tree, tree, int, bool*)':
> ../../gcc/gcc/config/avr/avr.cc:10391:45: error: unquoted sequence of 3 consecutive punctuation characters '...' in format [-Werror=format-diag]
> 10391 | warning_at (loc, OPT_Wattributes, "%qE attribute address out of "
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 10392 | "range 0x%x...0x%x", name, (int) io_start, (int) io_end);
> | ~~~~~~~~~~~~~~~~~~~
> cc1plus: all warnings being treated as errors
> make[1]: *** [Makefile:2554: avr.o] Error 1
> make[1]: Leaving directory '/var/lib/laminar/run/gcc-avr-elf/64/toolchain-build/gcc'
> make: *** [Makefile:4676: all-gcc] Error 2
>
>
> I think this should be "%<...%>".
>
> MfG, JBG
Hi,
thanks for sorting this out. I would install the patch below.
I must admit that I don't understand that warning and what is
illegal about having ellipses in a format string at that place.
That warning isn't even documented, at least as of 2024-02-12
https://gcc.gnu.org/onlinedocs/gcc/Option-Index.html
There should be no quotes around the ellipses, they are intended
as real ellipses.
Plus, I saw in other modules that it warns about format strings
like printf (";%i", 10); Why is ";" not allowed there?
Johann
--
diff --git a/gcc/config/avr/avr.cc b/gcc/config/avr/avr.cc
index 0cdd035fa1a..4bc3cf929de 100644
--- a/gcc/config/avr/avr.cc
+++ b/gcc/config/avr/avr.cc
@@ -10388,8 +10388,8 @@ avr_handle_addr_attribute (tree *node, tree
name, tree args,
&& (!tree_fits_shwi_p (arg)
|| ! IN_RANGE (TREE_INT_CST_LOW (arg), io_start,
io_end)))
{
- warning_at (loc, OPT_Wattributes, "%qE attribute address out of "
- "range 0x%x...0x%x", name, (int) io_start, (int)
io_end);
+ warning_at (loc, OPT_Wattributes, "%qE attribute address out
of range"
+ " 0x%x%s0x%x", name, (int) io_start, "...", (int)
io_end);
*no_add = true;
}
else
prev parent reply other threads:[~2024-01-12 12:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-04 16:28 Georg-Johann Lay
2024-01-12 3:37 ` Jan-Benedict Glaw
2024-01-12 12:32 ` Georg-Johann Lay [this message]
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=bbba4fbf-d194-49e6-9460-d7c847d5d2c6@gjlay.de \
--to=avr@gjlay.de \
--cc=chertykov@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jbglaw@lug-owl.de \
/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).