Am 12.01.24 um 04:37 schrieb Jan-Benedict Glaw:
On Thu, 2024-01-04 17:28:02 +0100, Georg-Johann Lay <a...@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

Reply via email to