xref: /llvm-project/clang/test/Preprocessor/embed_preprocess_to_file.c (revision 41c6e4379204ffc00948edd33d59ba5ebbceaba2)
1 // RUN: %clang_cc1 -std=c23 %s -E --embed-dir=%S/Inputs | FileCheck %s --check-prefix EXPANDED
2 // RUN: %clang_cc1 -std=c23 %s -E -dE --embed-dir=%S/Inputs | FileCheck %s --check-prefix DIRECTIVE
3 
4 // Ensure that we correctly preprocess to a file, both with expanding embed
5 // directives fully and with printing the directive instead.
6 const char data[] = {
7 #embed <jk.txt> if_empty('a', 'b') clang::offset(0) limit(1) suffix(, 'a', 0) prefix('h',)
8 };
9 
10 // EXPANDED: const char data[] = {'h',106 , 'a', 0};
11 // DIRECTIVE: const char data[] = {
12 // DIRECTIVE-NEXT: #embed <jk.txt> if_empty('a', 'b') limit(1) clang::offset(0) prefix('h',) suffix(, 'a', 0) /* clang -E -dE */
13 // DIRECTIVE-NEXT: };
14 
15 const char more[] = {
16 #embed <media/empty> if_empty('a', 'b')
17 };
18 
19 // EXPANDED: const char more[] = {'a', 'b'}
20 // DIRECTIVE: const char more[] = {
21 // DIRECTIVE-NEXT: #embed <media/empty> if_empty('a', 'b') /* clang -E -dE */
22 // DIRECTIVE-NEXT: };
23 
24 const char even_more[] = {
25   1, 2, 3,
26 #embed <jk.txt> prefix(4, 5,) suffix(, 6, 7)
27   , 8, 9, 10
28 };
29 
30 // EXPANDED: const char even_more[] = {
31 // EXPANDED-NEXT:   1, 2, 3,4, 5,106, 107 , 6, 7 , 8, 9, 10
32 // EXPANDED-EMPTY:
33 // EXPANDED-EMPTY:
34 // EXPANDED-NEXT: };
35 // DIRECTIVE: const char even_more[] = {
36 // DIRECTIVE-NEXT:  1, 2, 3,
37 // DIRECTIVE-NEXT: #embed <jk.txt> prefix(4, 5,) suffix(, 6, 7) /* clang -E -dE */
38 // DIRECTIVE-NEXT:  , 8, 9, 10
39 // DIRECTIVE-NEXT: };
40