comparison clang/test/Sema/format-strings-gnu.c @ 236:c4bab56944e8 llvm-original

LLVM 16
author kono
date Wed, 09 Nov 2022 17:45:10 +0900
parents 1d019706d866
children
comparison
equal deleted inserted replaced
232:70dce7da266c 236:c4bab56944e8
7 // RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-unknown-freebsd -DALLOWED %s 7 // RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-unknown-freebsd -DALLOWED %s
8 8
9 int printf(const char *restrict, ...); 9 int printf(const char *restrict, ...);
10 int scanf(const char * restrict, ...) ; 10 int scanf(const char * restrict, ...) ;
11 11
12 void test() { 12 void test(void) {
13 long notLongEnough = 1; 13 long notLongEnough = 1;
14 long long quiteLong = 2; 14 long long quiteLong = 2;
15 15
16 printf("%Ld", notLongEnough); // expected-warning {{format specifies type 'long long' but the argument has type 'long'}} 16 printf("%Ld", notLongEnough); // expected-warning {{format specifies type 'long long' but the argument has type 'long'}}
17 printf("%Ld", quiteLong); 17 printf("%Ld", quiteLong);
27 #ifndef MS 27 #ifndef MS
28 printf("%Z\n", quiteLong); // expected-warning{{invalid conversion specifier 'Z'}} 28 printf("%Z\n", quiteLong); // expected-warning{{invalid conversion specifier 'Z'}}
29 #endif 29 #endif
30 } 30 }
31 31
32 void testAlwaysInvalid() { 32 void testAlwaysInvalid(void) {
33 // We should not suggest 'll' here! 33 // We should not suggest 'll' here!
34 printf("%Lc", 'a'); // expected-warning {{length modifier 'L' results in undefined behavior or no effect with 'c' conversion specifier}} 34 printf("%Lc", 'a'); // expected-warning {{length modifier 'L' results in undefined behavior or no effect with 'c' conversion specifier}}
35 printf("%Ls", "a"); // expected-warning {{length modifier 'L' results in undefined behavior or no effect with 's' conversion specifier}} 35 printf("%Ls", "a"); // expected-warning {{length modifier 'L' results in undefined behavior or no effect with 's' conversion specifier}}
36 } 36 }
37 37