[flang] Fix crash in HLFIR generation (#118399)
[llvm-project.git] / clang / test / Sema / format-strings-signedness-fixit.c
blobb4e6e975657aaed4f1b5b3e439f610d4215cfec5
1 // RUN: cp %s %t
2 // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -Wformat -Wformat-signedness -fixit %t
3 // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -Wformat -Wformat-signedness -Werror %t
4 // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -E -o - %t | FileCheck %s
6 #include <limits.h>
8 int printf(const char *restrict format, ...);
10 void test_printf_int(int x)
12 printf("%u", x);
15 void test_printf_unsigned(unsigned x)
17 printf("%d", x);
20 void test_printf_long(long x)
22 printf("%lu", x);
25 void test_printf_unsigned_long(unsigned long x)
27 printf("%ld", x);
30 void test_printf_long_long(long long x)
32 printf("%llu", x);
35 void test_printf_unsigned_long_long(unsigned long long x)
37 printf("%lld", x);
40 enum enum_int {
41 minus_1 = -1
44 void test_printf_enum_int(enum enum_int x)
46 printf("%u", x);
49 enum enum_unsigned {
50 zero = 0
53 void test_printf_enum_unsigned(enum enum_unsigned x)
55 printf("%d", x);
58 enum enum_long {
59 minus_one = -1,
60 int_val = INT_MAX,
61 unsigned_val = (unsigned)INT_MIN
64 void test_printf_enum_long(enum enum_long x)
66 printf("%lu", x);
69 enum enum_unsigned_long {
70 uint_max_plus = (unsigned long)UINT_MAX+1,
73 void test_printf_enum_unsigned_long(enum enum_unsigned_long x)
75 printf("%ld", x);
78 // Validate the fixes.
79 // CHECK: void test_printf_int(int x)
80 // CHECK: printf("%d", x);
81 // CHECK: void test_printf_unsigned(unsigned x)
82 // CHECK: printf("%u", x);
83 // CHECK: void test_printf_long(long x)
84 // CHECK: printf("%ld", x);
85 // CHECK: void test_printf_unsigned_long(unsigned long x)
86 // CHECK: printf("%lu", x);
87 // CHECK: void test_printf_long_long(long long x)
88 // CHECK: printf("%lld", x);
89 // CHECK: void test_printf_unsigned_long_long(unsigned long long x)
90 // CHECK: printf("%llu", x);
91 // CHECK: void test_printf_enum_int(enum enum_int x)
92 // CHECK: printf("%d", x);
93 // CHECK: void test_printf_enum_unsigned(enum enum_unsigned x)
94 // CHECK: printf("%u", x);
95 // CHECK: void test_printf_enum_long(enum enum_long x)
96 // CHECK: printf("%ld", x);
97 // CHECK: void test_printf_enum_unsigned_long(enum enum_unsigned_long x)
98 // CHECK: printf("%lu", x);