| 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 |
| 5 |
|
| 6 |
// expected-no-diagnostics |
| 7 |
|
| 8 |
#define IsEqual(L, R) (__builtin_strcmp(L, R) == 0) |
| 9 |
|
| 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(); |
| 14 |
|
| 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 |
| 22 |
|
| 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 |
| 31 |
|
| 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"), ""); |
| 36 |
|
| 37 |
_Static_assert(__builtin_COLUMN() == __builtin_strlen("_Static_assert(_"), ""); |
| 38 |
|
| 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 |
| 44 |
} |
| 45 |
#endif // CONST_STRINGS |