From 3089352edbf03a16157cf4843b517c54a718fb11 Mon Sep 17 00:00:00 2001 From: Dmitry-Me Date: Fri, 27 Oct 2017 22:25:34 +0300 Subject: [PATCH] Improve test coverage for %lld used with printf --- test/testio.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/testio.cpp b/test/testio.cpp index a4637bd53..a3b320d38 100644 --- a/test/testio.cpp +++ b/test/testio.cpp @@ -2182,6 +2182,20 @@ private: "[test.cpp:6]: (warning) %lx in format string (no. 1) requires 'unsigned long' but the argument type is 'unsigned int'.\n" "[test.cpp:7]: (warning) %llx in format string (no. 1) requires 'unsigned long long' but the argument type is 'unsigned int'.\n", errout.str()); + check("void foo(int i, intmax_t im, ptrdiff_t p) {\n" + " printf(\"%lld\", i);\n" + " printf(\"%lld\", im);\n" + " printf(\"%lld\", p);\n" + "}"); + ASSERT_EQUALS("[test.cpp:2]: (warning) %lld in format string (no. 1) requires 'long long' but the argument type is 'signed int'.\n", errout.str()); + + check("void foo(intmax_t im, ptrdiff_t p) {\n" + " printf(\"%lld\", im);\n" + " printf(\"%lld\", p);\n" + "}", false, true, Settings::Win64); + ASSERT_EQUALS("[test.cpp:2]: (portability) %lld in format string (no. 1) requires 'long long' but the argument type is 'intmax_t {aka signed long long}'.\n" + "[test.cpp:3]: (portability) %lld in format string (no. 1) requires 'long long' but the argument type is 'ptrdiff_t {aka signed long long}'.\n", errout.str()); + check("class Foo {\n" " double d;\n" " struct Bar {\n"