https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88638

--- Comment #3 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> I submitted the patch below for review.  Dominique, if you have
> an opportunity to test it on Darwin and let me know if there are
> any outstanding problems that would be great.
> https://gcc.gnu.org/ml/gcc-patches/2019-01/msg00181.html

The patch for c-family/c-attribs.c no longer applies due to revision r267591: I
used

--- ../_clean/gcc/c-family/c-attribs.c  2019-01-05 05:45:01.000000000 +0100
+++ gcc/c-family/c-attribs.c    2019-01-05 06:04:49.000000000 +0100
@@ -632,16 +632,12 @@ positional_argument (const_tree fntype, 
        }

       bool type_match;
-      if (code == STRING_CST && POINTER_TYPE_P (argtype))
-       {
-         /* Where the expected code is STRING_CST accept any pointer
-            to a narrow character type, qualified or otherwise.  */
-         tree type = TREE_TYPE (argtype);
-         type = TYPE_MAIN_VARIANT (type);
-         type_match = (type == char_type_node
-                       || type == signed_char_type_node
-                       || type == unsigned_char_type_node);
-       }
+      if (code == STRING_CST)
+       /* Where the expected code is STRING_CST accept any pointer
+          expected by attribute format (this includes possibly qualified
+          char pointers and, for targets like Darwin, also pointers to
+          struct CFString).  */
+       type_match = valid_format_string_type_p (argtype);
       else if (code == INTEGER_TYPE)
        /* For integers, accept enums, wide characters and other types
           that match INTEGRAL_TYPE_P except for bool.  */
@@ -652,6 +648,21 @@ positional_argument (const_tree fntype, 

       if (!type_match)
        {
+         if (code == STRING_CST)
+           {
+             /* Reject invalid format strings with an error.  */
+             if (argno < 1)
+               error ("%qE attribute argument value %qE refers to "
+                      "parameter type %qT",
+                      atname, pos, argtype);
+             else
+               error ("%qE attribute argument %i value %qE refers to "
+                      "parameter type %qT",
+                      atname, argno, pos, argtype);
+
+             return NULL_TREE;
+           }
+
          if (argno < 1)
            warning (OPT_Wattributes,
                     "%qE attribute argument value %qE refers to "

A quick tests showed that it fixed the reported failures.

Reply via email to