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