1 // RUN: %clang_cc1 -std=c90 -fconst-strings -DCONST_STRINGS -verify %s
2 // RUN: %clang_cc1 -std=c90 -verify %s
3
4 // expected-no-diagnostics
5
6 #define IsEqual(L, R) (__builtin_strcmp(L, R) == 0)
7
8 const char *const FILE = __builtin_FILE();
9 const char *const FUNC = __builtin_FUNCTION();
10 const unsigned LINE = __builtin_LINE();
11 const unsigned COL = __builtin_COLUMN();
12
13 #ifndef CONST_STRINGS
14 char *const NCFILE = __builtin_FILE();
15 char *const NCFUNC = __builtin_FUNCTION();
16 #endif
17
18 #ifdef CONST_STRINGS
19 _Static_assert(IsEqual(__builtin_FILE(), __FILE__), "");
20 _Static_assert(__builtin_LINE() == __LINE__, "");
21 _Static_assert(IsEqual("", __builtin_FUNCTION()), "");
22
23 #line 42 "my_file.c"
24 _Static_assert(__builtin_LINE() == 42, "");
25 _Static_assert(IsEqual(__builtin_FILE(), "my_file.c"), "");
26
27 _Static_assert(__builtin_COLUMN() == __builtin_strlen("_Static_assert(_"), "");
28
foo()29 void foo() {
30 _Static_assert(IsEqual(__builtin_FUNCTION(), "foo"), "");
31 }
32 #endif // CONST_STRINGS
33