]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR c/37743 (Bogus printf format warning with __builtin_bswap32.)
authorJakub Jelinek <jakub@redhat.com>
Thu, 6 Mar 2014 08:11:20 +0000 (09:11 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 6 Mar 2014 08:11:20 +0000 (09:11 +0100)
Backport from mainline
2014-02-19  Jakub Jelinek  <jakub@redhat.com>

PR c/37743
* c-common.c (c_common_nodes_and_builtins): When initializing
c_uint{16,32,64}_type_node, also set corresponding
uint{16,32,64}_type_node to the same value.

* g++.dg/ext/builtin-bswap1.C: New test.
* c-c++-common/pr37743.c: New test.

From-SVN: r208371

gcc/c-family/ChangeLog
gcc/c-family/c-common.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/pr37743.c [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/builtin-bswap1.C [new file with mode: 0644]

index 779365bc76044f05fdba40f62102f6b169af5358..a18bb5cbae00a699f2a3732104cd3d46ecd51cdd 100644 (file)
@@ -1,6 +1,13 @@
 2014-03-06  Jakub Jelinek  <jakub@redhat.com>
 
        Backport from mainline
+       2014-02-19  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/37743
+       * c-common.c (c_common_nodes_and_builtins): When initializing
+       c_uint{16,32,64}_type_node, also set corresponding
+       uint{16,32,64}_type_node to the same value.
+
        2014-02-12  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/60101
index 983db79c95c2c8f43a05f126fa7fbae0037553c3..b7c68d7c0695f02c30775e32802482c1676f4d7d 100644 (file)
@@ -5506,13 +5506,13 @@ c_common_nodes_and_builtins (void)
     uint8_type_node =
       TREE_TYPE (identifier_global_value (c_get_ident (UINT8_TYPE)));
   if (UINT16_TYPE)
-    c_uint16_type_node =
+    c_uint16_type_node = uint16_type_node =
       TREE_TYPE (identifier_global_value (c_get_ident (UINT16_TYPE)));
   if (UINT32_TYPE)
-    c_uint32_type_node =
+    c_uint32_type_node = uint32_type_node =
       TREE_TYPE (identifier_global_value (c_get_ident (UINT32_TYPE)));
   if (UINT64_TYPE)
-    c_uint64_type_node =
+    c_uint64_type_node = uint64_type_node =
       TREE_TYPE (identifier_global_value (c_get_ident (UINT64_TYPE)));
   if (INT_LEAST8_TYPE)
     int_least8_type_node =
index 253b0a65b18d0969a03d2cb88c8fcea039a9d1dd..bf107a89615602e1c541b0410dc55d99c9505420 100644 (file)
@@ -3,6 +3,10 @@
        Backport from mainline
        2014-02-19  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c/37743
+       * g++.dg/ext/builtin-bswap1.C: New test.
+       * c-c++-common/pr37743.c: New test.
+
        PR preprocessor/58844
        * c-c++-common/cpp/pr58844-1.c: New test.
        * c-c++-common/cpp/pr58844-2.c: New test.
diff --git a/gcc/testsuite/c-c++-common/pr37743.c b/gcc/testsuite/c-c++-common/pr37743.c
new file mode 100644 (file)
index 0000000..2ea678e
--- /dev/null
@@ -0,0 +1,13 @@
+/* PR c/37743 */
+/* This needs to be run only on targets where __UINT32_TYPE__ is defined
+   to unsigned int.  */
+/* { dg-do compile { target *-*-linux-gnu* } } */
+/* { dg-options "-Wformat" } */
+
+int foo (const char *, ...) __attribute__ ((format (printf, 1, 2)));
+
+void
+bar (unsigned int x)
+{
+  foo ("%x", __builtin_bswap32 (x));
+}
diff --git a/gcc/testsuite/g++.dg/ext/builtin-bswap1.C b/gcc/testsuite/g++.dg/ext/builtin-bswap1.C
new file mode 100644 (file)
index 0000000..787ecba
--- /dev/null
@@ -0,0 +1,22 @@
+// PR c/37743
+// { dg-do compile }
+
+#if defined(__UINT32_TYPE__) && defined(__INT32_TYPE__)
+
+void foo (__UINT32_TYPE__);
+void foo (__INT32_TYPE__);
+
+void
+bar (__UINT32_TYPE__ x)
+{
+  foo (__builtin_bswap32 (x));
+}
+
+#else
+
+void
+bar ()
+{
+}
+
+#endif