[Bug target/88638] [9 Regression] FAIL: *string-format-1.* on darwin

2019-01-14 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88638

--- Comment #5 from Martin Sebor  ---
Author: msebor
Date: Mon Jan 14 18:44:00 2019
New Revision: 267922

URL: https://gcc.gnu.org/viewcvs?rev=267922=gcc=rev
Log:
PR target/88638 - FAIL: fsf-nsstring-format-1.s on darwin

gcc/c-family/ChangeLog:

PR target/88638
* c-attribs.c (positional_argument): Call valid_format_string_type_p
and issue errors if it fails.
* c-common.h (valid_format_string_type_p): Declare.
* c-format.c (valid_stringptr_type_p): Rename...
(valid_format_string_type_p): ...to this and make extern.
(handle_format_arg_attribute): Adjust to new name.
(check_format_string): Same.

gcc/testsuite/ChangeLog:

PR target/88638
* gcc.dg/format/attr-8.c: New test.
* gcc.dg/darwin-cfstring-format-1.c: Adjust diagnostics.
* gcc.dg/format/attr-3.c: Same.
* obj-c++.dg/fsf-nsstring-format-1.mm: Same.
* objc.dg/fsf-nsstring-format-1.m: Same.

gcc/ChangeLog:

PR target/88638
* doc/extend.texi (Darwin Format Checks): Clarify.


Added:
trunk/gcc/testsuite/gcc.dg/format/attr-8.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/c-family/ChangeLog
trunk/gcc/c-family/c-attribs.c
trunk/gcc/c-family/c-common.h
trunk/gcc/c-family/c-format.c
trunk/gcc/doc/extend.texi
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/gcc.dg/darwin-cfstring-format-1.c
trunk/gcc/testsuite/gcc.dg/format/attr-3.c
trunk/gcc/testsuite/obj-c++.dg/fsf-nsstring-format-1.mm
trunk/gcc/testsuite/objc.dg/fsf-nsstring-format-1.m

[Bug target/88638] [9 Regression] FAIL: *string-format-1.* on darwin

2019-01-14 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88638

Martin Sebor  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #4 from Martin Sebor  ---
Fixed via r267922.

[Bug target/88638] [9 Regression] FAIL: *string-format-1.* on darwin

2019-01-05 Thread dominiq at lps dot ens.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88638

--- Comment #3 from Dominique d'Humieres  ---
> 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.0 +0100
+++ gcc/c-family/c-attribs.c2019-01-05 06:04:49.0 +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.

[Bug target/88638] [9 Regression] FAIL: *string-format-1.* on darwin

2019-01-04 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88638

Martin Sebor  changed:

   What|Removed |Added

   Keywords||patch

--- Comment #2 from Martin Sebor  ---
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

[Bug target/88638] [9 Regression] FAIL: *string-format-1.* on darwin

2019-01-02 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88638

Martin Sebor  changed:

   What|Removed |Added

   Keywords||diagnostic
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2019-01-02
 Ever confirmed|0   |1

--- Comment #1 from Martin Sebor  ---
At a minimum, the warning on line 15 is not intended.  The change in r266195
needs to also take Objective C strings into account analogously to how they are
being handled by valid_stringptr_type_p() in c-format.c.

[Bug target/88638] [9 Regression] FAIL: *string-format-1.* on darwin

2019-01-02 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88638

Martin Sebor  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |msebor at gcc dot 
gnu.org

[Bug target/88638] [9 Regression] FAIL: *string-format-1.* on darwin

2019-01-02 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88638

Richard Biener  changed:

   What|Removed |Added

Version|unknown |9.0
   Target Milestone|--- |9.0