re PR middle-end/54486 (Spurious printf format warning mentions nonexistent type...
authorJakub Jelinek <jakub@redhat.com>
Wed, 5 Sep 2012 16:27:55 +0000 (18:27 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 5 Sep 2012 16:27:55 +0000 (18:27 +0200)
PR middle-end/54486
* builtins.c (fold_builtin_strspn, fold_builtin_strcspn): Use
build_int_cst with size_type_node instead of size_int.

* c-c++-common/pr54486.c: New test.

From-SVN: r190986

gcc/ChangeLog
gcc/builtins.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/pr54486.c [new file with mode: 0644]

index 73e5f209182a3080a41987a587cac4af67b67eb1..8bfc5ce1b2e6b550bc920ffa5ad9000fee7d32e7 100644 (file)
@@ -1,3 +1,9 @@
+2012-09-05  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/54486
+       * builtins.c (fold_builtin_strspn, fold_builtin_strcspn): Use
+       build_int_cst with size_type_node instead of size_int.
+
 2012-09-05  Uros Bizjak  <ubizjak@gmail.com>
 
        * config/i386/sse.md (<sse4_1>_blendv<ssemodesuffix><avxsizesuffix>):
index 4b177c48e65e9c09261ce152a8ed7e02294e4d37..26f5d4812035e362f7812e23df49552da0077af7 100644 (file)
@@ -11890,7 +11890,7 @@ fold_builtin_strspn (location_t loc, tree s1, tree s2)
       if (p1 && p2)
        {
          const size_t r = strspn (p1, p2);
-         return size_int (r);
+         return build_int_cst (size_type_node, r);
        }
 
       /* If either argument is "", return NULL_TREE.  */
@@ -11935,7 +11935,7 @@ fold_builtin_strcspn (location_t loc, tree s1, tree s2)
       if (p1 && p2)
        {
          const size_t r = strcspn (p1, p2);
-         return size_int (r);
+         return build_int_cst (size_type_node, r);
        }
 
       /* If the first argument is "", return NULL_TREE.  */
index 4598e6695134a97a06a5e1d955cb89332ca3052f..c33fddce09707d9257f0dd59feaed5143a45d75e 100644 (file)
@@ -1,3 +1,8 @@
+2012-09-05  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/54486
+       * c-c++-common/pr54486.c: New test.
+
 2012-09-05  Dominique Dhumieres  <dominiq@lps.ens.fr>
 
        PR fortran/54474
diff --git a/gcc/testsuite/c-c++-common/pr54486.c b/gcc/testsuite/c-c++-common/pr54486.c
new file mode 100644 (file)
index 0000000..e8125fc
--- /dev/null
@@ -0,0 +1,32 @@
+/* PR middle-end/54486 */
+/* { dg-do compile } */
+/* { dg-options "-Wformat" } */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+typedef __SIZE_TYPE__ size_t;
+extern int printf (const char *, ...);
+extern size_t strspn (const char *, const char *);
+extern size_t strcspn (const char *, const char *);
+extern size_t strlen (const char *);
+#ifdef __cplusplus
+}
+#endif
+
+void
+foo (void)
+{
+  printf ("%zu\n", strspn ("abc", "abcdefg"));
+  printf ("%zu\n", (size_t) strspn ("abc", "abcdefg"));
+  printf ("%zu\n", __builtin_strspn ("abc", "abcdefg"));
+  printf ("%zu\n", (size_t) __builtin_strspn ("abc", "abcdefg"));
+  printf ("%zu\n", strcspn ("abc", "abcdefg"));
+  printf ("%zu\n", (size_t) strcspn ("abc", "abcdefg"));
+  printf ("%zu\n", __builtin_strcspn ("abc", "abcdefg"));
+  printf ("%zu\n", (size_t) __builtin_strcspn ("abc", "abcdefg"));
+  printf ("%zu\n", strlen ("abc"));
+  printf ("%zu\n", (size_t) strlen ("abc"));
+  printf ("%zu\n", __builtin_strlen ("abc"));
+  printf ("%zu\n", (size_t) __builtin_strlen ("abc"));
+}