[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Sema / source_location.c
blobe0030c634dd882c30cfc69bb8298c2c6894e3838
1 // RUN: %clang_cc1 -std=c90 -fconst-strings -DCONST_STRINGS -verify %s
2 // RUN: %clang_cc1 -std=c90 -verify %s
3 // RUN: %clang_cc1 -std=c90 -fms-extensions -DMS -fconst-strings -DCONST_STRINGS -verify %s
4 // RUN: %clang_cc1 -std=c90 -fms-extensions -DMS -verify %s
6 // expected-no-diagnostics
8 #define IsEqual(L, R) (__builtin_strcmp(L, R) == 0)
10 const char *const FILE = __builtin_FILE();
11 const char *const FUNC = __builtin_FUNCTION();
12 const unsigned LINE = __builtin_LINE();
13 const unsigned COL = __builtin_COLUMN();
15 #ifndef CONST_STRINGS
16 char *const NCFILE = __builtin_FILE();
17 char *const NCFUNC = __builtin_FUNCTION();
18 #ifdef MS
19 char *const NCFNSG = __builtin_FUNCSIG();
20 #endif
21 #endif
23 #ifdef CONST_STRINGS
24 _Static_assert(IsEqual(__builtin_FILE(), __FILE__), "");
25 _Static_assert(IsEqual(__builtin_FILE_NAME(), __FILE_NAME__), "");
26 _Static_assert(__builtin_LINE() == __LINE__, "");
27 _Static_assert(IsEqual("", __builtin_FUNCTION()), "");
28 #ifdef MS
29 _Static_assert(IsEqual("", __builtin_FUNCSIG()), "");
30 #endif
32 #line 42 "my_file.c"
33 _Static_assert(__builtin_LINE() == 42, "");
34 _Static_assert(IsEqual(__builtin_FILE(), "my_file.c"), "");
35 _Static_assert(IsEqual(__builtin_FILE_NAME(), "my_file.c"), "");
37 _Static_assert(__builtin_COLUMN() == __builtin_strlen("_Static_assert(_"), "");
39 void foo(void) {
40 _Static_assert(IsEqual(__builtin_FUNCTION(), "foo"), "");
41 #ifdef MS
42 _Static_assert(IsEqual(__builtin_FUNCSIG(), "void __cdecl foo(void)"), "");
43 #endif
45 #endif // CONST_STRINGS