mingw32: Fix warning, update documentation
Commit Message
Hi!
The mingw32 port is the only port to have TARGET_OVERRIDES_FORMAT_ATTRIBUTES
defined. When this macro is defined, it will never evaluate to NULL, so this
check just leads to a warning:
/usr/lib/gcc-snapshot/bin/g++ -fcf-protection -fno-PIE -c -DIN_GCC_FRONTEND -DIN_GCC_FRONTEND -DIN_GCC_FRONTEND -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 -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror -fno-common -DHAVE_CONFIG_H -I. -Ic-family -I../../gcc/gcc -I../../gcc/gcc/c-family -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include -I../../gcc/gcc/../libcody -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/bid -I../libdecnumber -I../../gcc/gcc/../libbacktrace -o c-family/c-format.o -MT c-family/c-format.o -MMD -MP -MF c-family/.deps/c-format.TPo ../../gcc/gcc/c-family/c-format.cc
../../gcc/gcc/c-family/c-format.cc: In function 'const char* convert_format_name_to_system_name(const char*)':
../../gcc/gcc/c-family/c-format.cc:5114:42: error: the address of 'mingw_format_attribute_overrides' will never be NULL [-Werror=address]
5114 | if (TARGET_OVERRIDES_FORMAT_ATTRIBUTES != NULL
In file included from ./tm.h:26,
from ../../gcc/gcc/c-family/c-format.cc:23:
../../gcc/gcc/config/i386/mingw32.h:268:44: note: 'mingw_format_attribute_overrides' declared here
268 | #define TARGET_OVERRIDES_FORMAT_ATTRIBUTES mingw_format_attribute_overrides
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../gcc/gcc/c-family/c-format.cc:5079:30: note: in expansion of macro 'TARGET_OVERRIDES_FORMAT_ATTRIBUTES'
5079 | extern const target_ovr_attr TARGET_OVERRIDES_FORMAT_ATTRIBUTES[];
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
make[1]: *** [Makefile:1146: c-family/c-format.o] Error 1
make[1]: Leaving directory '/var/lib/laminar/run/gcc-x86_64-w64-mingw32/1/toolchain-build/gcc'
make: *** [Makefile:4588: all-gcc] Error 2
Also, when TARGET_OVERRIDES_FORMAT_ATTRIBUTES is defined,
TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT must be defined as well. Add
that requirement to the docs.
2022-09-07 Jan-Benedict Glaw <jbglaw@lug-owl.de>
gcc/ChangeLog:
* c-family/c-format.cc (convert_format_name_to_system_name): Fix warning.
* doc/tm.texi.in (TARGET_OVERRIDES_FORMAT_ATTRIBUTES): Document requirement
of TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT being defined as well.
* doc/tm.texi: Regenerate.
Okay for HEAD?
Thanks,
Jan-Benedict
--
Comments
On 9/8/22 11:02, Jan-Benedict Glaw wrote:
> Hi!
>
>
> The mingw32 port is the only port to have TARGET_OVERRIDES_FORMAT_ATTRIBUTES
> defined. When this macro is defined, it will never evaluate to NULL, so this
> check just leads to a warning:
>
> /usr/lib/gcc-snapshot/bin/g++ -fcf-protection -fno-PIE -c -DIN_GCC_FRONTEND -DIN_GCC_FRONTEND -DIN_GCC_FRONTEND -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 -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror -fno-common -DHAVE_CONFIG_H -I. -Ic-family -I../../gcc/gcc -I../../gcc/gcc/c-family -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include -I../../gcc/gcc/../libcody -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/bid -I../libdecnumber -I../../gcc/gcc/../libbacktrace -o c-family/c-format.o -MT c-family/c-format.o -MMD -MP -MF c-family/.deps/c-format.TPo ../../gcc/gcc/c-family/c-format.cc
> ../../gcc/gcc/c-family/c-format.cc: In function 'const char* convert_format_name_to_system_name(const char*)':
> ../../gcc/gcc/c-family/c-format.cc:5114:42: error: the address of 'mingw_format_attribute_overrides' will never be NULL [-Werror=address]
> 5114 | if (TARGET_OVERRIDES_FORMAT_ATTRIBUTES != NULL
> In file included from ./tm.h:26,
> from ../../gcc/gcc/c-family/c-format.cc:23:
> ../../gcc/gcc/config/i386/mingw32.h:268:44: note: 'mingw_format_attribute_overrides' declared here
> 268 | #define TARGET_OVERRIDES_FORMAT_ATTRIBUTES mingw_format_attribute_overrides
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ../../gcc/gcc/c-family/c-format.cc:5079:30: note: in expansion of macro 'TARGET_OVERRIDES_FORMAT_ATTRIBUTES'
> 5079 | extern const target_ovr_attr TARGET_OVERRIDES_FORMAT_ATTRIBUTES[];
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> cc1plus: all warnings being treated as errors
> make[1]: *** [Makefile:1146: c-family/c-format.o] Error 1
> make[1]: Leaving directory '/var/lib/laminar/run/gcc-x86_64-w64-mingw32/1/toolchain-build/gcc'
> make: *** [Makefile:4588: all-gcc] Error 2
>
>
>
> Also, when TARGET_OVERRIDES_FORMAT_ATTRIBUTES is defined,
> TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT must be defined as well. Add
> that requirement to the docs.
>
>
> 2022-09-07 Jan-Benedict Glaw <jbglaw@lug-owl.de>
>
> gcc/ChangeLog:
> * c-family/c-format.cc (convert_format_name_to_system_name): Fix warning.
> * doc/tm.texi.in (TARGET_OVERRIDES_FORMAT_ATTRIBUTES): Document requirement
> of TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT being defined as well.
> * doc/tm.texi: Regenerate.
>
> diff --git a/gcc/c-family/c-format.cc b/gcc/c-family/c-format.cc
> index 68b94da40cc..a6c380bf1c8 100644
> --- a/gcc/c-family/c-format.cc
> +++ b/gcc/c-family/c-format.cc
> @@ -5111,8 +5111,7 @@ convert_format_name_to_system_name (const char *attr_name)
>
> #ifdef TARGET_OVERRIDES_FORMAT_ATTRIBUTES
> /* Check if format attribute is overridden by target. */
> - if (TARGET_OVERRIDES_FORMAT_ATTRIBUTES != NULL
> - && TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT > 0)
> + if (TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT > 0)
> {
> for (i = 0; i < TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT; ++i)
> {
> diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
> index 5312059ea79..21b849ea32a 100644
> --- a/gcc/doc/tm.texi.in
> +++ b/gcc/doc/tm.texi.in
> @@ -7836,7 +7836,8 @@ If defined, this macro is the number of entries in
> If defined, this macro is the name of a global variable containing
> target-specific format overrides for the @option{-Wformat} option. The
> default is to have no target-specific format overrides. If defined,
> -@code{TARGET_FORMAT_TYPES} must be defined, too.
> +@code{TARGET_FORMAT_TYPES} and @code{TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT}
> +must be defined, too.
> @end defmac
>
> @defmac TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT
> diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
> index e47bf28089a..858bfb80cec 100644
> --- a/gcc/doc/tm.texi
> +++ b/gcc/doc/tm.texi
> @@ -12043,7 +12043,8 @@ If defined, this macro is the number of entries in
> If defined, this macro is the name of a global variable containing
> target-specific format overrides for the @option{-Wformat} option. The
> default is to have no target-specific format overrides. If defined,
> -@code{TARGET_FORMAT_TYPES} must be defined, too.
> +@code{TARGET_FORMAT_TYPES} and @code{TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT}
> +must be defined, too.
> @end defmac
>
> @defmac TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT
>
>
> Okay for HEAD?
>
> Thanks,
> Jan-Benedict
>
Looks good to me, thanks for working on it.
@@ -5111,8 +5111,7 @@ convert_format_name_to_system_name (const char *attr_name)
#ifdef TARGET_OVERRIDES_FORMAT_ATTRIBUTES
/* Check if format attribute is overridden by target. */
- if (TARGET_OVERRIDES_FORMAT_ATTRIBUTES != NULL
- && TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT > 0)
+ if (TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT > 0)
{
for (i = 0; i < TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT; ++i)
{
@@ -7836,7 +7836,8 @@ If defined, this macro is the number of entries in
If defined, this macro is the name of a global variable containing
target-specific format overrides for the @option{-Wformat} option. The
default is to have no target-specific format overrides. If defined,
-@code{TARGET_FORMAT_TYPES} must be defined, too.
+@code{TARGET_FORMAT_TYPES} and @code{TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT}
+must be defined, too.
@end defmac
@defmac TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT
@@ -12043,7 +12043,8 @@ If defined, this macro is the number of entries in
If defined, this macro is the name of a global variable containing
target-specific format overrides for the @option{-Wformat} option. The
default is to have no target-specific format overrides. If defined,
-@code{TARGET_FORMAT_TYPES} must be defined, too.
+@code{TARGET_FORMAT_TYPES} and @code{TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT}
+must be defined, too.
@end defmac
@defmac TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT