annotate clang/test/Sema/source_location.c @ 222:81f6424ef0e3 llvm-original

LLVM original branch
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 18 Jul 2021 22:10:01 +0900
parents 1d019706d866
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -std=c90 -fconst-strings -DCONST_STRINGS -verify %s
anatofuz
parents:
diff changeset
2 // RUN: %clang_cc1 -std=c90 -verify %s
anatofuz
parents:
diff changeset
3
anatofuz
parents:
diff changeset
4 // expected-no-diagnostics
anatofuz
parents:
diff changeset
5
anatofuz
parents:
diff changeset
6 #define IsEqual(L, R) (__builtin_strcmp(L, R) == 0)
anatofuz
parents:
diff changeset
7
anatofuz
parents:
diff changeset
8 const char *const FILE = __builtin_FILE();
anatofuz
parents:
diff changeset
9 const char *const FUNC = __builtin_FUNCTION();
anatofuz
parents:
diff changeset
10 const unsigned LINE = __builtin_LINE();
anatofuz
parents:
diff changeset
11 const unsigned COL = __builtin_COLUMN();
anatofuz
parents:
diff changeset
12
anatofuz
parents:
diff changeset
13 #ifndef CONST_STRINGS
anatofuz
parents:
diff changeset
14 char *const NCFILE = __builtin_FILE();
anatofuz
parents:
diff changeset
15 char *const NCFUNC = __builtin_FUNCTION();
anatofuz
parents:
diff changeset
16 #endif
anatofuz
parents:
diff changeset
17
anatofuz
parents:
diff changeset
18 #ifdef CONST_STRINGS
anatofuz
parents:
diff changeset
19 _Static_assert(IsEqual(__builtin_FILE(), __FILE__), "");
anatofuz
parents:
diff changeset
20 _Static_assert(__builtin_LINE() == __LINE__, "");
anatofuz
parents:
diff changeset
21 _Static_assert(IsEqual("", __builtin_FUNCTION()), "");
anatofuz
parents:
diff changeset
22
anatofuz
parents:
diff changeset
23 #line 42 "my_file.c"
anatofuz
parents:
diff changeset
24 _Static_assert(__builtin_LINE() == 42, "");
anatofuz
parents:
diff changeset
25 _Static_assert(IsEqual(__builtin_FILE(), "my_file.c"), "");
anatofuz
parents:
diff changeset
26
anatofuz
parents:
diff changeset
27 _Static_assert(__builtin_COLUMN() == __builtin_strlen("_Static_assert(_"), "");
anatofuz
parents:
diff changeset
28
anatofuz
parents:
diff changeset
29 void foo() {
anatofuz
parents:
diff changeset
30 _Static_assert(IsEqual(__builtin_FUNCTION(), "foo"), "");
anatofuz
parents:
diff changeset
31 }
anatofuz
parents:
diff changeset
32 #endif // CONST_STRINGS