annotate clang/test/Preprocessor/expr_define_expansion.c @ 236:c4bab56944e8 llvm-original

LLVM 16
author kono
date Wed, 09 Nov 2022 17:45:10 +0900
parents 1d019706d866
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 %s -E -CC -verify
anatofuz
parents:
diff changeset
2 // RUN: %clang_cc1 %s -E -CC -DPEDANTIC -pedantic -verify
anatofuz
parents:
diff changeset
3
anatofuz
parents:
diff changeset
4 #define FOO && 1
anatofuz
parents:
diff changeset
5 #if defined FOO FOO
anatofuz
parents:
diff changeset
6 #endif
anatofuz
parents:
diff changeset
7
anatofuz
parents:
diff changeset
8 #define A
anatofuz
parents:
diff changeset
9 #define B defined(A)
anatofuz
parents:
diff changeset
10 #if B // expected-warning{{macro expansion producing 'defined' has undefined behavior}}
anatofuz
parents:
diff changeset
11 #endif
anatofuz
parents:
diff changeset
12
anatofuz
parents:
diff changeset
13 #define m_foo
anatofuz
parents:
diff changeset
14 #define TEST(a) (defined(m_##a) && a)
anatofuz
parents:
diff changeset
15
anatofuz
parents:
diff changeset
16 #if defined(PEDANTIC)
anatofuz
parents:
diff changeset
17 // expected-warning@+4{{macro expansion producing 'defined' has undefined behavior}}
anatofuz
parents:
diff changeset
18 #endif
anatofuz
parents:
diff changeset
19
anatofuz
parents:
diff changeset
20 // This shouldn't warn by default, only with pedantic:
anatofuz
parents:
diff changeset
21 #if TEST(foo)
anatofuz
parents:
diff changeset
22 #endif
anatofuz
parents:
diff changeset
23
anatofuz
parents:
diff changeset
24
anatofuz
parents:
diff changeset
25 // Only one diagnostic for this case:
anatofuz
parents:
diff changeset
26 #define INVALID defined(
anatofuz
parents:
diff changeset
27 #if INVALID // expected-error{{macro name missing}}
anatofuz
parents:
diff changeset
28 #endif