Skip to content

Commit 279487b

Browse files
committed
Pre-Commit test: [Clang][Preprocessor] Enable macro expansion **only** in directives when parsing preprocessed sources
1 parent 0dc15b1 commit 279487b

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// RUN: %clang_cc1 -E -x c %s | FileCheck %s
2+
// RUN: %clang_cc1 -x c -fsyntax-only %s -verify
3+
// expected-no-diagnostics
4+
// RUN: %clang_cc1 -x cpp-output -fsyntax-only -verify=fail %s
5+
6+
// The preprocessor does not expand macro-identifiers in #pragma directives.
7+
// When we preprocess & parse the code, clang expands the macros in directives.
8+
// When we parse already preprocessed code, clang still has to expand the
9+
// macros in the directives.
10+
// This means that we're not always able to parse the preprocessor's output
11+
// without preserving the definitions (-dD).
12+
13+
#define FACTOR 4
14+
15+
void foo() {
16+
// CHECK: #pragma unroll FACTOR
17+
#pragma unroll FACTOR // fail-error{{use of undeclared identifier}}
18+
for(;;) {
19+
}
20+
return;
21+
}

0 commit comments

Comments
 (0)