]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix "address will never be NULL" warning
authorJan-Benedict Glaw <jbglaw@lug-owl.de>
Fri, 9 Sep 2022 08:27:27 +0000 (10:27 +0200)
committerJan-Benedict Glaw <jbglaw@lug-owl.de>
Fri, 9 Sep 2022 08:30:43 +0000 (10:30 +0200)
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 and produce
a warning: "error: the address of 'mingw_format_attribute_overrides' will never
be NULL [-Werror=address]"

  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/c-family/ChangeLog:
* c-format.cc (convert_format_name_to_system_name): Fix warning.
gcc/ChangeLog:
* doc/tm.texi.in (TARGET_OVERRIDES_FORMAT_ATTRIBUTES): Document requirement
of TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT being defined as well.
* doc/tm.texi: Regenerate.

gcc/c-family/c-format.cc
gcc/doc/tm.texi
gcc/doc/tm.texi.in

index 68b94da40cc2f664f31d56bae84b79055b5afa58..a6c380bf1c87d9b13ec2cc7c26f1f0730536f9f1 100644 (file)
@@ -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)
         {
index e47bf28089a6e9fb4f72cc03a2961f071d160c45..858bfb80cec6ebae0081dfd2162ae86c8f826a7a 100644 (file)
@@ -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
index 5312059ea79149a9d065076617a5a5e8653aa624..21b849ea32a187708d43a7d54b1265127c71624d 100644 (file)
@@ -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