brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.7 KiB · 2705b5e Raw
80 lines · c
1// RUN: %clang_cc1 -std=c23 %s -E --embed-dir=%S/Inputs -verify2// expected-no-diagnostics3 4#if __has_embed(__FILE__) != __STDC_EMBED_FOUND__5#error 16#elif __has_embed("media/art.txt") != __STDC_EMBED_FOUND__7#error 28#elif __has_embed("asdkasdjkadsjkdsfjk") != __STDC_EMBED_NOT_FOUND__9#error 310#elif __has_embed("asdkasdjkadsjkdsfjk" limit(1)) != __STDC_EMBED_NOT_FOUND__11#error 412#elif __has_embed("asdkasdjkadsjkdsfjk" suffix(x) limit(1)) != __STDC_EMBED_NOT_FOUND__13#error 514#elif __has_embed("asdkasdjkadsjkdsfjk" suffix(x) djsakdasjd::xmeow("xD")) != __STDC_EMBED_NOT_FOUND__15#error 616#elif __has_embed(__FILE__ limit(2) prefix(y)) != __STDC_EMBED_FOUND__17#error 718#elif __has_embed(__FILE__ limit(2)) != __STDC_EMBED_FOUND__19#error 820// 6.10.1p7, if the search fails or any of the embed parameters in the embed21// parameter sequence specified are not supported by the implementation for the22// #embed directive;23// We don't support one of the embed parameters.24#elif __has_embed(__FILE__ dajwdwdjdahwk::meow(x)) != __STDC_EMBED_NOT_FOUND__25#error 926#elif __has_embed(<media/empty>) != __STDC_EMBED_EMPTY__27#error 1028// 6.10.1p7: if the search for the resource succeeds and all embed parameters29// in the embed parameter sequence specified are supported by the30// implementation for the #embed directive and the resource is empty31// Limiting to zero characters means the resource is empty.32#elif __has_embed(<media/empty> limit(0)) != __STDC_EMBED_EMPTY__33#error 1134#elif __has_embed(<media/art.txt> limit(0)) != __STDC_EMBED_EMPTY__35#error 1236// 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__38#error 1339// Test that we apply the offset before we apply the limit. If we did this in40// the reverse order, this would cause the file to be empty because we would41// 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__43#error 1444#elif __has_embed(<media/art.txt>) != __STDC_EMBED_FOUND__45#error 1546#elif __has_embed(<media/art.txt> if_empty(meow)) != __STDC_EMBED_FOUND__47#error 1648#endif49 50// Ensure that when __has_embed returns true, the file can actually be51// embedded. This was previously failing because the way in which __has_embed52// would search for files was differentl from how #embed would resolve them53// when the file path included relative path markers like `./` or `../`.54#if __has_embed("./embed___has_embed.c") == __STDC_EMBED_FOUND__55unsigned char buffer[] = {56#embed "./embed___has_embed.c"57};58#else59#error 1760#endif61 62#if __has_embed(__FILE__\63)64#else65#error 1866#endif67 68#define F __FI\69LE__70#if __has_embed(F)71#else72#error 1973#endif74 75#if __has_embed(F\76)77#else 78#error 2079#endif80