OSDN Git Service

PR middle-end/54486
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 5 Sep 2012 16:29:42 +0000 (16:29 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 5 Sep 2012 16:29:42 +0000 (16:29 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@190987 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 88f5610..304bc08 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  Georg-Johann Lay  <avr@gjlay.de>
 
        Backport from 2012-09-05 mainline r190697.
index a086a8c..04980cc 100644 (file)
@@ -11927,7 +11927,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.  */
@@ -11972,7 +11972,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 9094558..193bb1c 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  Joey Ye  <joey.ye@arm.com>
 
        Backported from trunk
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"));
+}