blob: 7d76826828245f13fee3b3aadd7b9d5948a6b3c1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
// RUN: %clang_cc1 -std=c23 %s --embed-dir=%S/Inputs -fsyntax-only -verify
const char data[] = {
#embed <single_byte.txt> suffix(, '\xA')
};
const char empty_data[] = {
#embed <media/empty> suffix(, '\xA')
1
};
static_assert(sizeof(data) == 2);
static_assert('b' == data[0]);
static_assert('\xA' == data[1]);
static_assert(sizeof(empty_data) == 1);
static_assert(1 == empty_data[0]);
struct S {
int x, y, z;
};
const struct S s = {
#embed <single_byte.txt> suffix( , .y = 100, .z = 10 )
};
static_assert(s.x == 'b');
static_assert(s.y == 100);
static_assert(s.z == 10);
// Ensure that an empty file does not produce any suffix tokens. If it did,
// there would be random tokens here that the parser would trip on.
#embed <media/empty> suffix(0)
// Ensure we diagnose duplicate parameters even if they're the same value.
const unsigned char a[] = {
#embed <jk.txt> suffix(,1) prefix() suffix(,1)
// expected-error@-1 {{cannot specify parameter 'suffix' twice in the same '#embed' directive}}
,
#embed <jk.txt> suffix(,1) if_empty() suffix(,2)
// expected-error@-1 {{cannot specify parameter 'suffix' twice in the same '#embed' directive}}
};
|