1 // RUN: %clang_cc1 -std=c23 %s -E --embed-dir=%S/Inputs -verify
2 // expected-no-diagnostics
4 #if __has_embed(__FILE__) != __STDC_EMBED_FOUND__
6 #elif __has_embed("media/art.txt") != __STDC_EMBED_FOUND__
8 #elif __has_embed("asdkasdjkadsjkdsfjk") != __STDC_EMBED_NOT_FOUND__
10 #elif __has_embed("asdkasdjkadsjkdsfjk" limit(1)) != __STDC_EMBED_NOT_FOUND__
12 #elif __has_embed("asdkasdjkadsjkdsfjk" suffix(x) limit(1)) != __STDC_EMBED_NOT_FOUND__
14 #elif __has_embed("asdkasdjkadsjkdsfjk" suffix(x) djsakdasjd::xmeow("xD")) != __STDC_EMBED_NOT_FOUND__
16 #elif __has_embed(__FILE__ limit(2) prefix(y)) != __STDC_EMBED_FOUND__
18 #elif __has_embed(__FILE__ limit(2)) != __STDC_EMBED_FOUND__
20 // 6.10.1p7, if the search fails or any of the embed parameters in the embed
21 // parameter sequence specified are not supported by the implementation for the
23 // We don't support one of the embed parameters.
24 #elif __has_embed(__FILE__ dajwdwdjdahwk::meow(x)) != __STDC_EMBED_NOT_FOUND__
26 #elif __has_embed(<media/empty>) != __STDC_EMBED_EMPTY__
28 // 6.10.1p7: if the search for the resource succeeds and all embed parameters
29 // in the embed parameter sequence specified are supported by the
30 // implementation for the #embed directive and the resource is empty
31 // Limiting to zero characters means the resource is empty.
32 #elif __has_embed(<media/empty> limit(0)) != __STDC_EMBED_EMPTY__
34 #elif __has_embed(<media/art.txt> limit(0)) != __STDC_EMBED_EMPTY__
36 // Test that an offset past the end of the file produces an empty file.
37 #elif __has_embed(<single_byte.txt> clang::offset(1)) != __STDC_EMBED_EMPTY__
39 // Test that we apply the offset before we apply the limit. If we did this in
40 // the reverse order, this would cause the file to be empty because we would
41 // have limited it to 1 byte and then offset past it.
42 #elif __has_embed(<media/art.txt> limit(1) clang::offset(12)) != __STDC_EMBED_FOUND__
44 #elif __has_embed(<media/art.txt>) != __STDC_EMBED_FOUND__
46 #elif __has_embed(<media/art.txt> if_empty(meow)) != __STDC_EMBED_FOUND__
50 // Ensure that when __has_embed returns true, the file can actually be
51 // embedded. This was previously failing because the way in which __has_embed
52 // would search for files was differentl from how #embed would resolve them
53 // when the file path included relative path markers like `./` or `../`.
54 #if __has_embed("./embed___has_embed.c") == __STDC_EMBED_FOUND__
55 unsigned char buffer
[] = {
56 #embed "./embed___has_embed.c"