OSDN Git Service

* c-format.c (CPLUSPLUS_STD_VER): Define to STD_C94.
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 2 Oct 2001 07:06:56 +0000 (07:06 +0000)
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 2 Oct 2001 07:06:56 +0000 (07:06 +0000)
testsuite:
* g++.dg/warn/format1.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@45941 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/c-format.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/format1.C [new file with mode: 0644]

index b75dfe6..afccd79 100644 (file)
@@ -1,3 +1,7 @@
+2001-10-02  Joseph S. Myers  <jsm28@cam.ac.uk>
+
+       * c-format.c (CPLUSPLUS_STD_VER): Define to STD_C94.
+
 2001-10-01  Jim Wilson  <wilson@redhat.com>
 
        * sched-deps.c (add_dependence): When elide conditional dependence,
index e25c29e..3cc880e 100644 (file)
@@ -497,7 +497,7 @@ enum format_std_version
 
 /* The C standard version C++ is treated as equivalent to
    or inheriting from, for the purpose of format features supported.  */
-#define CPLUSPLUS_STD_VER      STD_C89
+#define CPLUSPLUS_STD_VER      STD_C94
 /* The C standard version we are checking formats against when pedantic.  */
 #define C_STD_VER              ((int)(c_language == clk_cplusplus        \
                                 ? CPLUSPLUS_STD_VER                      \
index 624b55e..997762c 100644 (file)
@@ -1,3 +1,7 @@
+2001-10-02  Joseph S. Myers  <jsm28@cam.ac.uk>
+
+       * g++.dg/warn/format1.C: New test.
+
 2001-10-01  Neil Booth  <neil@daikokuya.demon.co.uk>
 
        * mi6.c, mi6a.h, mi6b.h, mi6c.h, mi6d.h, mi6e.h: Correct tests.
diff --git a/gcc/testsuite/g++.dg/warn/format1.C b/gcc/testsuite/g++.dg/warn/format1.C
new file mode 100644 (file)
index 0000000..27bc414
--- /dev/null
@@ -0,0 +1,15 @@
+// Test that formats get checked according to C94.
+// Origin: Joseph Myers <jsm28@cam.ac.uk>.
+// { dg-do compile }
+// { dg-options "-ansi -pedantic -Wformat" }
+
+#include <cstdio>
+
+void
+foo (int i, int *ip, __WINT_TYPE__ lc, wchar_t *ls)
+{
+  std::printf ("%d%ls%lc\n", i, ls, lc);
+  std::printf ("%d", ls); // { dg-warning "format" "printf warning" }
+  std::scanf ("%d%lc%ls%l[abc]", ip, ls, ls, ls);
+  std::scanf ("%hd", ip); // { dg-warning "format" "scanf warning" }
+}