[Sema] Fix format-strings test on 32-bit Arm#178450
Conversation
|
@llvm/pr-subscribers-clang Author: Leandro Lupori (luporl) ChangesFull diff: https://github.com/llvm/llvm-project/pull/178450.diff 1 Files Affected:
diff --git a/clang/test/Sema/format-strings.c b/clang/test/Sema/format-strings.c
index cdac83fc0bb91..3a2c2701cfcfc 100644
--- a/clang/test/Sema/format-strings.c
+++ b/clang/test/Sema/format-strings.c
@@ -3,10 +3,12 @@
// RUN: %clang_cc1 -fblocks -fsyntax-only -verify -Wformat-nonliteral -isystem %S/Inputs -triple=x86_64-unknown-fuchsia %s
// RUN: %clang_cc1 -fblocks -fsyntax-only -verify -Wformat-nonliteral -isystem %S/Inputs -triple=x86_64-linux-android %s
+#include <limits.h>
#include <stdarg.h>
#include <stddef.h>
#define __need_wint_t
#include <stddef.h> // For wint_t and wchar_t
+#include <stdint.h>
typedef struct _FILE FILE;
int fprintf(FILE *, const char *restrict, ...);
@@ -986,8 +988,16 @@ void test_promotion(void) {
void test_bool(_Bool b, _Bool* bp)
{
+#if SIZE_MAX != UINT_MAX
printf("%zu", b); // expected-warning-re{{format specifies type 'size_t' (aka '{{.+}}') but the argument has type '_Bool'}}
+#else
+ printf("%zu", b); // no-warning
+#endif
+#if PTRDIFF_MAX != INT_MAX
printf("%td", b); // expected-warning-re{{format specifies type 'ptrdiff_t' (aka '{{.+}}') but the argument has type '_Bool'}}
+#else
+ printf("%td", b); // no-warning
+#endif
printf("%jd", b); // expected-warning-re{{format specifies type 'intmax_t' (aka '{{.+}}') but the argument has type '_Bool'}}
printf("%lld", b); // expected-warning{{format specifies type 'long long' but the argument has type '_Bool'}}
printf("%ld", b); // expected-warning{{format specifies type 'long' but the argument has type '_Bool'}}
|
|
I'm merging this PR to fix the buildbots. If necessary, the tests can be improved later. |
|
This PR is causing the test to fail on AIX: https://lab.llvm.org/buildbot/#/builders/64/builds/7039 It seems that the warning still occurs even when |
Interesting. It seems both Does the following work on AIX? #if SIZE_MAX > UINT_MAX || UINT_MAX == ULONG_MAX
printf("%zu", b); // expected-warning-re{{format specifies type 'size_t' (aka '{{.+}}') but the argument has type '_Bool'}}
#else
printf("%zu", b); // no-warning
#endif
#if PTRDIFF_MAX > INT_MAX || INT_MAX == LONG_MAX
printf("%td", b); // expected-warning-re{{format specifies type 'ptrdiff_t' (aka '{{.+}}') but the argument has type '_Bool'}}
#else
printf("%td", b); // no-warning
#endif |
Thanks, yes it does. |
No description provided.