Hi!

Here is an updated patch.  It fixes one-liner in files.cc (|| instead of
&&), fixes -fdirectives-only preprocessing of #embed (it isn't 100% in the
spirit of -fdirectives-only mode, because for the tokens from
prefix/suffix/if_empty clauses it has to actually preprocess them and can't
leave them as is, while
#define FOO a + b + c +
#embed __FILE__ prefix(FOO) limit(2)
perhaps could be somehow in theory preprocessed into
 FOO 35,100
#define BAR a + b + c + ) suffix (d
#embed __FILE__ prefix(BAR) limit(2)
can't, so this patch emits
 a + b + c + 35,100
and
  a + b + c + 35,100 d
there even in -fdirectives-only mode.  And for -traditional-cpp, the patch
just errors out, I'm afraid #embed is quite incompatible with the
traditional preprocessing and people using traditional preprocessing IMNSHO
shouldn't be encountering #embed nor __has_embed.
Additionally, I've added documentation for the directive and operators.
While initially I thought that is not needed because C23 documents that,
I've noticed we actually document how #include/#define etc. behaves even
when the standards define that too, it is useful to explain what search
paths are searched and we need some spot where to document extensions (the
gnu:: namespace parameters).

What follows is the previous description:
The following patch implements the C23 N3017 "#embed - a scannable,
tooling-friendly binary resource inclusion mechanism" paper.

The implementation is intentionally dumb, in that it doesn't significantly
speed up compilation of larger initializers and doesn't make it possible
to use huge #embeds (like several gigabytes large, that is compile time
and memory still infeasible).
There are 2 reasons for this.  One is that I think like it is implemented
now in the patch is how we should use it for the smaller #embed sizes,
dunno with which boundary, whether 32 bytes or 64 or something like that,
certainly handling the single byte cases which is something that can appear
anywhere in the source where constant integer literal can appear is
desirable and I think for a few bytes it isn't worth it to come up with
something smarter and users would like to e.g. see it in -E readably as
well (perhaps the slow vs. fast boundary should be determined by command
line option).  And the other one is to be able to more easily find
regressions in behavior caused by the optimizations, so we have something
to get back in git to compare against.
I'm definitely willing to work on the optimizations (likely introduce a new
CPP_* token type to refer to a range of libcpp owned memory (start + size)
and similarly some tree which can do the same, and can be at any time e.g.
split into 2 subparts + say INTEGER_CST in between if needed say for
const unsigned char d[] = {
#embed "2GB.dat" prefix (0, 0, ) suffix (, [0x40000000] = 42)
}; still without having to copy around huge amounts of data; STRING_CST
owns the memory it points to and can be only 2GB in size), but would
like to do that incrementally.
And would like to first include some extensions also not included in
this patch, like gnu::offset (off) parameter to allow to skip certain
constant amount of bytes at the start of the files, plus
gnu::base64 ("base64_encoded_data") parameter to add something which can
store more efficiently large amounts of the #embed data in preprocessed
source.

I've been cross-checking all the tests also against the LLVM implementation
https://github.com/llvm/llvm-project/pull/68620
which has been for a few hours even committed to LLVM trunk but reverted
afterwards.

The patch uses --embed-dir= option that clang plans to add above and doesn't
use other variants on the search directories yet, plus there are no
default directories at least for the time being where to search for embed
files.  So, #embed "..." works if it is found in the same directory (or
relative to the current file's directory) and #embed "/..." or #embed </...>
work always, but relative #embed <...> doesn't unless at least one
--embed-dir= is specified.  There is no reason to differentiate between
system and non-system directories, so we don't need -isystem like
counterpart, perhaps -iquote like counterpart could be useful in the future,
dunno what else.  Should we have --embed-directory= as alias to --embed-dir=?

There are some differences beyond clang ICEs, so I'd like to point them out
to make sure there is agreement on the choices in the patch.  They are also
mentioned in the comments of the llvm pull request.

The most important is that the GCC patch (as well as the original thephd.dev
LLVM branch on godbolt) expands #embed (or acts as if it is expanded) into
a mere sequence of numbers like 123,2,35,26 rather then what clang
effectively treats as (unsigned char)123,(unsigned char)2,(unsigned
char)35,(unsigned char)26 but only does that when using integrated
preprocessor, not when using -save-temps where it acts as GCC.
JeanHeyd as the original author agrees that is how it is currently worded in
C23.

Another difference (not tested in the testsuite, not sure how to check for
effective target /dev/urandom nor am sure it is desirable to check that
during testsuite) is how to treat character devices, named pipes etc.
(block devices are errored on).  The original paper uses /dev/urandom
in various examples and seems to assume that unlike regular files the
devices aren't really cached, so
#embed </dev/urandom> limit(1) prefix(int a = ) suffix(;)
#embed </dev/urandom> limit(1) prefix(int b = ) suffix(;)
usually results in a != b.  That is what the godbolt thephd.dev branch
implements too and what this patch does as well, but clang actually seems
to just go from st.st_size == 0, ergo it must be zero-sized resource and
so just copies over if_empty if present.  It is really questionable
what to do about the character devices/named pipes with __has_embed, for
regular files the patch doesn't read anything from them, relies on
st.st_size + limit for whether it is empty or non-empty.  But I don't know
of a way to check if read on say a character device would read anything
or not (the </dev/null> limit (1) vs. </dev/zero> limit (1) cases), and
if we read something, that would be better cached for later because
#embed later if it reads again could read no further data even when it
first read something.  So, the patch currently for __has_embed just
always returns 2 on the non-regular files, like the thephd.dev
branch does as well and like the clang pull request as well.
A question is also what to do for gnu::offset on the non-regular files
even for #embed, those aren't seekable and do we want to just read and throw
away the offset bytes each time we see it used?

clang also chokes on the
#if __has_embed (__FILE__ __limit__ (1) __prefix__ () suffix (1 / 0) \
__if_empty__ ((({{[0[0{0{0(0(0)1)1}1}]]}})))) != __STDC_EMBED_FOUND__
#error "__has_embed fail"
#endif
in embed-1.c, but thephd.dev branch accepts it and I don't see why
it shouldn't, (({{[0[0{0{0(0(0)1)1}1}]]}}))) is a balanced token
sequence and the file isn't empty, so it should just be parsed and
discarded.

clang also IMHO mishandles
const unsigned char w[] = {
#embed __FILE__ prefix([0] = 42, [15] =) limit(32)
};
but again only without -save-temps, seems like it
treats it as
[0] = 42, [15] = (99,111,110,115,116,32,117,110,115,105,103,110,101,100,
32,99,104,97,114,32,119,91,93,32,61,32,123,10,35,101,109,98)
rather than
[0] = 42, [15] = 99,111,110,115,116,32,117,110,115,105,103,110,101,100,
32,99,104,97,114,32,119,91,93,32,61,32,123,10,35,101,109,98
and warns on it for -Wunused-value and just compiles it as
[0] = 42, [15] = 98

And also
void foo (int, int, int, int);
void bar (void) { foo (
#embed __FILE__ limit (4) prefix (172 + ) suffix (+ 2)
); }
is treated as
172 + (118, 111, 105, 100) + 2
rather than
172 + 118, 111, 105, 100 + 2
which clang -save-temps or GCC treats it like, so results
in just one argument passed rather than 4.

if (!strstr ((const char *) magna_carta, "imprisonétur")) abort ();
in the testcase fails as well, but in that case calling it in gdb succeeds:
p ((char *(*)(char *, char *))__strstr_sse2) (magna_carta, "imprisonétur")
$2 = 0x555555558d3c <magna_carta+11564> "imprisonétur aut disseisiátur"...
so I guess they are just trying to constant evaluate strstr and do it
incorrectly.

They started with making the optimizations together in the initial patch
set, so they don't have the luxury to compare if it is just because of
the optimization they are trying to do or because that is how the
feature works for them.  At least unless they use -save-temps for now.

There is also different behavior between clang and gcc on -M or other
dependency generating options.  Seems clang includes the __has_embed
searched files in dependencies, while my patch doesn't.  But so does
clang for __has_include and GCC doesn't.  Emitting a hard dependency
on some header just because there was __has_include/__has_embed for it
seems wrong to me, because (at least when properly written) the source
likely doesn't mind if the file is missing, it will do something else,
so a hard error from make because of it doesn't seem right.  Does
make have some weaker dependencies, such that if some file can be remade
it is but if it doesn't exist, it isn't fatal?

I wonder whether #embed <non-existent-file> really needs to be fatal
or whether we could simply after diagnosing it pretend the file exists
and is empty.  For #include I think fatal errors make tons of sense,
but perhaps for #embed which is more localized we'd get better error
reporting if we didn't bail out immediately.  Note, both GCC and clang
currently treat those as fatal errors.

clang also added -dE option which with -E instead of preprocessing
the #embed directives keeps them as is, but the preprocessed source
then isn't self-contained.  That option looks more harmful than useful to
me.

Also, it isn't clear to me from C23 whether it is possible to have
__has_include/__has_c_attribute/__has_embed expressions inside of
the limit #embed/__has_embed argument.
6.10.3.2/2 says that defined should not appear there (and the patch
diagnoses it and testsuite tests), but for __has_include/__has_embed
etc. 6.10.1/11 says:
"The identifiers __has_include, __has_embed, and __has_c_attribute
shall not appear in any context not mentioned in this subclause."
If that subclause in that case means 6.10.1, then it presumably shouldn't
appear in #embed in 6.10.3, but __has_embed is in 6.10.1...
But 6.10.3.2/3 says that it should be parsed according to the 6.10.1
rules.  Haven't included tests like
#if __has_embed (__FILE__ limit (__has_embed (__FILE__ limit (1))))
or
#embed __FILE__ limit (__has_include (__FILE__))
into the testsuite because of the doubts but I think the patch should
handle those right now.

The reason I've used Magna Carta text in some of the testcases is that
I hope it shouldn't be copyrighted after the centuries and I'd strongly
prefer not to have binary blobs in git after the xz backdoor lesson
and wanted something larger which doesn't change all the time.

Oh, BTW, I see in C23 draft 6.10.3.2 in Example 4
if (f_source == NULL);
  return 1;
(note the spurious semicolon after closing paren), has that been fixed
already?

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2024-06-18  Jakub Jelinek  <ja...@redhat.com>

        PR c/105863
libcpp/
        * include/cpplib.h: Implement C23 N3017 #embed - a scannable,
        tooling-friendly binary resource inclusion mechanism paper.
        (enum cpp_builtin_type): Add BT_HAS_EMBED.
        (cpp_set_include_chains): Add another cpp_dir * argument to
        the declaration.
        * internal.h (enum include_type): Add IT_EMBED.
        (struct cpp_reader): Add embed_include member.
        (struct cpp_embed_params_tokens): New type.
        (struct cpp_embed_params): New type.
        (_cpp_get_token_no_padding): Declare.
        (enum _cpp_find_file_kind): Add _cpp_FFK_EMBED and _cpp_FFK_HAS_EMBED.
        (_cpp_stack_embed): Declare.
        (_cpp_parse_expr): Change return type to cpp_num_part instead of
        bool, change second argument from bool to const char * and add third
        argument.
        (_cpp_parse_embed_params): Declare.
        * directives.cc (DIRECTIVE_TABLE): Add embed entry.
        (end_directive): Don't call skip_rest_of_line for T_EMBED directive.
        (_cpp_handle_directive): Return 2 rather than 1 for T_EMBED in
        directives-only mode.
        (parse_include): Don't Call check_eol for T_EMBED directive.
        (skip_balanced_token_seq): New function.
        (_cpp_parse_embed_params): New function.
        (do_embed): New function.
        (do_if): Adjust _cpp_parse_expr caller.
        (do_elif): Likewise.
        * expr.cc (parse_defined): Diagnose defined in #embed or __has_embed
        parameters.
        (_cpp_parse_expr): Change return type to cpp_num_part instead of
        bool, change second argument from bool to const char * and add third
        argument.  Adjust function comment.  For #embed/__has_embed parameters
        add an artificial CPP_OPEN_PAREN.  Use the second argument DIR
        directly instead of string literals conditional on IS_IF.
        For #embed/__has_embed parameter, stop on reaching CPP_CLOSE_PAREN
        matching the artificial one.  Diagnose negative or too large embed
        parameter operands.
        (num_binary_op): Use #embed instead of #if for diagnostics if inside
        #embed/__has_embed parameter.
        (num_div_op): Likewise.
        * files.cc (struct _cpp_file): Add limit member and embed bitfield.
        (search_cache): Add IS_EMBED argument, formatting fix.  Skip over
        files with different file->embed from the argument.
        (find_file_in_dir): Don't call pch_open_file if file->embed.
        (_cpp_find_file): Handle _cpp_FFK_EMBED and _cpp_FFK_HAS_EMBED.
        (read_file_guts): Formatting fix.
        (has_unique_contents): Ignore file->embed files.
        (search_path_head): Handle IT_EMBED type.
        (_cpp_stack_embed): New function.
        (_cpp_get_file_stat): Formatting fix.
        (cpp_set_include_chains): Add embed argument, save it to
        pfile->embed_include and compute lens for the chain.
        * init.cc (builtin_array): Add __has_embed entry.
        (cpp_init_builtins): Predefine __STDC_EMBED_NOT_FOUND__,
        __STDC_EMBED_FOUND__ and __STDC_EMBED_EMPTY__.
        * lex.cc (cpp_directive_only_process): Handle #embed.
        * macro.cc (cpp_get_token_no_padding): Rename to ...
        (_cpp_get_token_no_padding): ... this.  No longer static.
        (builtin_has_include_1): New function.
        (builtin_has_include): Use it.  Use _cpp_get_token_no_padding
        instead of cpp_get_token_no_padding.
        (builtin_has_embed): New function.
        (_cpp_builtin_macro_text): Handle BT_HAS_EMBED.
gcc/
        * doc/cppdiropts.texi (--embed-dir=): Document.
        * doc/cpp.texi (Binary Resource Inclusion): New chapter.
        (__has_embed): Document.
        * doc/invoke.texi (Directory Options): Mention --embed-dir=.
        * gcc.cc (cpp_unique_options): Add %{-embed*}.
        * genmatch.cc (main): Adjust cpp_set_include_chains caller.
        * incpath.h (enum incpath_kind): Add INC_EMBED.
        * incpath.cc (merge_include_chains): Handle INC_EMBED.
        (register_include_chains): Adjust cpp_set_include_chains caller.
gcc/c-family/
        * c.opt (-embed-dir=): New option.
        * c-opts.cc (c_common_handle_option): Handle OPT__embed_dir_.
gcc/testsuite/
        * c-c++-common/cpp/embed-1.c: New test.
        * c-c++-common/cpp/embed-2.c: New test.
        * c-c++-common/cpp/embed-3.c: New test.
        * c-c++-common/cpp/embed-4.c: New test.
        * c-c++-common/cpp/embed-5.c: New test.
        * c-c++-common/cpp/embed-6.c: New test.
        * c-c++-common/cpp/embed-7.c: New test.
        * c-c++-common/cpp/embed-8.c: New test.
        * c-c++-common/cpp/embed-9.c: New test.
        * c-c++-common/cpp/embed-10.c: New test.
        * c-c++-common/cpp/embed-11.c: New test.
        * c-c++-common/cpp/embed-12.c: New test.
        * c-c++-common/cpp/embed-13.c: New test.
        * c-c++-common/cpp/embed-14.c: New test.
        * c-c++-common/cpp/embed-dir/embed-1.inc: New test.
        * c-c++-common/cpp/embed-dir/embed-3.c: New test.
        * c-c++-common/cpp/embed-dir/embed-4.c: New test.
        * c-c++-common/cpp/embed-dir/magna-carta.txt: New test.
        * gcc.dg/cpp/embed-1.c: New test.
        * gcc.dg/cpp/embed-2.c: New test.
        * gcc.dg/cpp/embed-3.c: New test.
        * gcc.dg/cpp/embed-4.c: New test.
        * g++.dg/cpp/embed-1.C: New test.
        * g++.dg/cpp/embed-2.C: New test.
        * g++.dg/cpp/embed-3.C: New test.

--- libcpp/include/cpplib.h.jj  2024-06-14 19:45:09.955770914 +0200
+++ libcpp/include/cpplib.h     2024-06-18 14:28:55.813706760 +0200
@@ -974,6 +975,7 @@ enum cpp_builtin_type
   BT_HAS_BUILTIN,              /* `__has_builtin(x)' */
   BT_HAS_INCLUDE,              /* `__has_include(x)' */
   BT_HAS_INCLUDE_NEXT,         /* `__has_include_next(x)' */
+  BT_HAS_EMBED,                        /* `__has_embed(x)' */
   BT_HAS_FEATURE,              /* `__has_feature(x)' */
   BT_HAS_EXTENSION             /* `__has_extension(x)' */
 };
@@ -1092,7 +1094,8 @@ extern void cpp_set_line_map (cpp_reader
 extern void cpp_set_lang (cpp_reader *, enum c_lang);
 
 /* Set the include paths.  */
-extern void cpp_set_include_chains (cpp_reader *, cpp_dir *, cpp_dir *, int);
+extern void cpp_set_include_chains (cpp_reader *, cpp_dir *, cpp_dir *,
+                                   cpp_dir *, int);
 
 /* Call these to get pointers to the options, callback, and deps
    structures for a given reader.  These pointers are good until you
--- libcpp/internal.h.jj        2024-06-14 19:44:34.669233804 +0200
+++ libcpp/internal.h   2024-06-18 13:22:57.174131387 +0200
@@ -122,6 +122,7 @@ enum include_type
    IT_INCLUDE,  /* #include */
    IT_INCLUDE_NEXT,  /* #include_next */
    IT_IMPORT,   /* #import  */
+   IT_EMBED,  /* #embed  */
 
    /* Non-directive including mechanisms.  */
    IT_CMDLINE,  /* -include */
@@ -463,6 +464,7 @@ struct cpp_reader
   struct cpp_dir *quote_include;       /* "" */
   struct cpp_dir *bracket_include;     /* <> */
   struct cpp_dir no_search_path;       /* No path.  */
+  struct cpp_dir *embed_include;       /* #embed <> */
 
   /* Chain of all hashed _cpp_file instances.  */
   struct _cpp_file *all_files;
@@ -614,6 +616,24 @@ struct cpp_reader
   }
 };
 
+/* Lists of tokens for #embed/__has_embed prefix/suffix/if_empty
+   parameters.  */
+struct cpp_embed_params_tokens
+{
+  cpp_token *cur_token;
+  tokenrun base_run, *cur_run;
+  size_t count;
+};
+
+/* #embed and __has_embed parameters.  */
+struct cpp_embed_params
+{
+  location_t loc;
+  bool has_embed;
+  cpp_num_part limit;
+  cpp_embed_params_tokens prefix, suffix, if_empty;
+};
+
 /* Character classes.  Based on the more primitive macros in safe-ctype.h.
    If the definition of `numchar' looks odd to you, please look up the
    definition of a pp-number in the C standard [section 6.4.8 of C99].
@@ -702,6 +722,7 @@ extern bool _cpp_arguments_ok (cpp_reade
 extern const unsigned char *_cpp_builtin_macro_text (cpp_reader *,
                                                     cpp_hashnode *,
                                                     location_t = 0);
+extern const cpp_token *_cpp_get_token_no_padding (cpp_reader *);
 extern int _cpp_warn_if_unused_macro (cpp_reader *, cpp_hashnode *, void *);
 extern void _cpp_push_token_context (cpp_reader *, cpp_hashnode *,
                                     const cpp_token *, unsigned int);
@@ -714,13 +735,16 @@ extern void _cpp_destroy_hashtable (cpp_
 
 /* In files.cc */
 enum _cpp_find_file_kind
-  { _cpp_FFK_NORMAL, _cpp_FFK_FAKE, _cpp_FFK_PRE_INCLUDE, _cpp_FFK_HAS_INCLUDE 
};
+  { _cpp_FFK_NORMAL, _cpp_FFK_FAKE, _cpp_FFK_PRE_INCLUDE, _cpp_FFK_HAS_INCLUDE,
+    _cpp_FFK_EMBED, _cpp_FFK_HAS_EMBED };
 extern _cpp_file *_cpp_find_file (cpp_reader *, const char *, cpp_dir *,
                                  int angle, _cpp_find_file_kind, location_t);
 extern bool _cpp_find_failed (_cpp_file *);
 extern void _cpp_mark_file_once_only (cpp_reader *, struct _cpp_file *);
 extern const char *_cpp_find_header_unit (cpp_reader *, const char *file,
                                          bool angle_p,  location_t);
+extern int _cpp_stack_embed (cpp_reader *, const char *, bool,
+                            cpp_embed_params *);
 extern void _cpp_fake_include (cpp_reader *, const char *);
 extern bool _cpp_stack_file (cpp_reader *, _cpp_file*, include_type, 
location_t);
 extern bool _cpp_stack_include (cpp_reader *, const char *, int,
@@ -739,7 +763,8 @@ extern bool _cpp_has_header (cpp_reader
                             enum include_type);
 
 /* In expr.cc */
-extern bool _cpp_parse_expr (cpp_reader *, bool);
+extern cpp_num_part _cpp_parse_expr (cpp_reader *, const char *,
+                                    const cpp_token *);
 extern struct op *_cpp_expand_op_stack (cpp_reader *);
 
 /* In lex.cc */
@@ -780,6 +805,7 @@ extern void _cpp_restore_pragma_names (c
 extern int _cpp_do__Pragma (cpp_reader *, location_t);
 extern void _cpp_init_directives (cpp_reader *);
 extern void _cpp_init_internal_pragmas (cpp_reader *);
+extern bool _cpp_parse_embed_params (cpp_reader *, struct cpp_embed_params *);
 extern void _cpp_do_file_change (cpp_reader *, enum lc_reason, const char *,
                                 linenum_type, unsigned int);
 extern void _cpp_pop_buffer (cpp_reader *);
--- libcpp/directives.cc.jj     2024-06-14 19:44:34.480236283 +0200
+++ libcpp/directives.cc        2024-06-18 15:43:04.149834580 +0200
@@ -159,6 +159,7 @@ static void cpp_pop_definition (cpp_read
   D(error,     T_ERROR,        STDC89,    0)                           \
   D(pragma,    T_PRAGMA,       STDC89,    IN_I)                        \
   D(warning,   T_WARNING,      STDC23,    0)                           \
+  D(embed,     T_EMBED,        STDC23,    INCL | EXPAND)               \
   D(include_next, T_INCLUDE_NEXT, EXTENSION, INCL | EXPAND)            \
   D(ident,     T_IDENT,        EXTENSION, IN_I)                        \
   D(import,    T_IMPORT,       EXTENSION, INCL | EXPAND)  /* ObjC */   \
@@ -326,7 +327,8 @@ end_directive (cpp_reader *pfile, int sk
   /* We don't skip for an assembler #.  */
   else if (skip_line)
     {
-      skip_rest_of_line (pfile);
+      if (pfile->directive != &dtable[T_EMBED])
+       skip_rest_of_line (pfile);
       if (!pfile->keep_tokens)
        {
          pfile->cur_run = &pfile->base_run;
@@ -569,7 +571,15 @@ _cpp_handle_directive (cpp_reader *pfile
     prepare_directive_trad (pfile);
 
   if (dir)
-    pfile->directive->handler (pfile);
+    {
+      pfile->directive->handler (pfile);
+      if (pfile->directive == &dtable[T_EMBED]
+         && skip
+         && CPP_OPTION (pfile, directives_only))
+       /* Signal to cpp_directive_only_process it needs to emit
+          the #embed expansion.  */
+       skip = 2;
+    }
   else if (skip == 0)
     _cpp_backup_tokens (pfile, 1);
 
@@ -821,9 +831,10 @@ parse_include (cpp_reader *pfile, int *p
       return NULL;
     }
 
-  if (pfile->directive == &dtable[T_PRAGMA])
+  if (pfile->directive == &dtable[T_PRAGMA]
+      || pfile->directive == &dtable[T_EMBED])
     {
-      /* This pragma allows extra tokens after the file name.  */
+      /* This pragma or #embed allows extra tokens after the file name.  */
     }
   else if (buf == NULL || CPP_OPTION (pfile, discard_comments))
     check_eol (pfile, true);
@@ -921,6 +932,324 @@ do_include_next (cpp_reader *pfile)
   do_include_common (pfile, type);
 }
 
+/* Skip over balanced preprocessing tokens until END is found.
+   If SAVE is non-NULL, remember the parsed tokens in it.  */
+
+static void
+skip_balanced_token_seq (cpp_reader *pfile, cpp_ttype end,
+                        cpp_embed_params_tokens *save, bool nested)
+{
+  do
+    {
+      const cpp_token *token = cpp_peek_token (pfile, 0);
+      if (token->type == CPP_EOF)
+       {
+         char c = 0;
+         switch (end)
+           {
+           case CPP_CLOSE_PAREN: c = '('; break;
+           case CPP_CLOSE_SQUARE: c = '['; break;
+           case CPP_CLOSE_BRACE: c = '{'; break;
+           default: abort ();
+           }
+         cpp_error (pfile, CPP_DL_ERROR, "unbalanced '%c'", c);
+         return;
+       }
+      token = cpp_get_token (pfile);
+      if (save
+         && (token->type != CPP_PADDING || save->count)
+         && (token->type != end || nested))
+       {
+         if (save->count == 0)
+           {
+             _cpp_init_tokenrun (&save->base_run, 4);
+             save->cur_run = &save->base_run;
+             save->cur_token = save->base_run.base;
+           }
+         else if (save->cur_token == save->cur_run->limit)
+           {
+             save->cur_run->next = XNEW (tokenrun);
+             save->cur_run->next->prev = save->cur_run;
+             _cpp_init_tokenrun (save->cur_run->next, 4);
+             save->cur_run = save->cur_run->next;
+             save->cur_token = save->cur_run->base;
+           }
+         *save->cur_token = *token;
+         save->cur_token->flags |= NO_EXPAND;
+         save->cur_token++;
+         save->count++;
+       }
+      if (token->type == end)
+       return;
+      switch (token->type)
+       {
+       case CPP_OPEN_PAREN:
+         skip_balanced_token_seq (pfile, CPP_CLOSE_PAREN, save, true);
+         break;
+       case CPP_OPEN_SQUARE:
+         skip_balanced_token_seq (pfile, CPP_CLOSE_SQUARE, save, true);
+         break;
+       case CPP_OPEN_BRACE:
+         skip_balanced_token_seq (pfile, CPP_CLOSE_BRACE, save, true);
+         break;
+       case CPP_CLOSE_PAREN:
+         cpp_error (pfile, CPP_DL_ERROR, "unbalanced '%c'", ')');
+         break;
+       case CPP_CLOSE_SQUARE:
+         cpp_error (pfile, CPP_DL_ERROR, "unbalanced '%c'", ']');
+         break;
+       case CPP_CLOSE_BRACE:
+         cpp_error (pfile, CPP_DL_ERROR, "unbalanced '%c'", '}');
+         break;
+       default:
+         break;
+       }
+    }
+  while (1);
+}
+
+/* Parse parameters of #embed directive or __has_embed expression.  */
+
+bool
+_cpp_parse_embed_params (cpp_reader *pfile, struct cpp_embed_params *params)
+{
+  const cpp_token *token = _cpp_get_token_no_padding (pfile);
+  bool ret = true;
+  int seen = 0;
+  params->limit = -1;
+  do
+    {
+      const unsigned char *param_name = NULL;
+      const unsigned char *param_prefix = NULL;
+      int param_name_len = 0, param_prefix_len = 0;
+      bool has_scope = false;
+      if (token->type != CPP_NAME)
+       {
+         if (token->type == CPP_EOF)
+           {
+             if (params->has_embed)
+               {
+                 cpp_error (pfile, CPP_DL_ERROR, "expected ')'");
+                 return false;
+               }
+             return ret;
+           }
+         else if (token->type == CPP_CLOSE_PAREN && params->has_embed)
+           return ret;
+         cpp_error (pfile, CPP_DL_ERROR, "expected parameter name");
+         return false;
+       }
+      param_name = NODE_NAME (token->val.node.spelling);
+      param_name_len = NODE_LEN (token->val.node.spelling);
+      location_t loc = token->src_loc;
+      token = _cpp_get_token_no_padding (pfile);
+      if (token->type == CPP_SCOPE)
+       {
+         has_scope = true;
+         token = _cpp_get_token_no_padding (pfile);
+       }
+      else if (token->type == CPP_COLON
+              && (token->flags & COLON_SCOPE) != 0)
+       {
+         has_scope = true;
+         token = _cpp_get_token_no_padding (pfile);
+         if (token->type != CPP_COLON)
+           {
+             cpp_error (pfile, CPP_DL_ERROR, "expected ':'");
+             return false;
+           }
+         token = _cpp_get_token_no_padding (pfile);
+       }
+      if (has_scope)
+       {
+         if (token->type != CPP_NAME)
+           {
+             cpp_error (pfile, CPP_DL_ERROR, "expected parameter name");
+             return false;
+           }
+         param_prefix = param_name;
+         param_prefix_len = param_name_len;
+         param_name = NODE_NAME (token->val.node.spelling);
+         param_name_len = NODE_LEN (token->val.node.spelling);
+         loc = token->src_loc;
+         token = _cpp_get_token_no_padding (pfile);
+       }
+      if (param_name_len > 4
+         && param_name[0] == '_'
+         && param_name[1] == '_'
+         && param_name[param_name_len - 1] == '_'
+         && param_name[param_name_len - 2] == '_')
+       {
+         param_name += 2;
+         param_name_len -= 4;
+       }
+      if (param_prefix
+         && param_prefix_len > 4
+         && param_prefix[0] == '_'
+         && param_prefix[1] == '_'
+         && param_prefix[param_prefix_len - 1] == '_'
+         && param_prefix[param_prefix_len - 2] == '_')
+       {
+         param_prefix += 2;
+         param_prefix_len -= 4;
+       }
+      size_t param_kind = -1;
+      if (param_prefix == NULL)
+       {
+         struct { int len; const char *name; } std_params[] = {
+           { 5, "limit" }, { 6, "prefix" },
+           { 6, "suffix" }, { 8, "if_empty" }
+         };
+         for (size_t i = 0;
+              i < sizeof (std_params) / sizeof (std_params[0]); ++i)
+           if (param_name_len == std_params[i].len
+               && memcmp (param_name, std_params[i].name,
+                          param_name_len) == 0)
+             {
+               param_kind = i;
+               break;
+             }
+       }
+      if (param_kind != (size_t) -1)
+       {
+         if ((seen & (1 << param_kind)) == 0)
+           seen |= 1 << param_kind;
+         else
+           cpp_error_with_line (pfile, CPP_DL_ERROR, loc, 0,
+                                "duplicate embed parameter '%.*s%s%.*s'",
+                                param_prefix_len,
+                                param_prefix
+                                ? (const char *) param_prefix : "",
+                                param_prefix ? "::" : "",
+                                param_name_len, param_name);
+       }
+      else
+       {
+         ret = false;
+         if (!params->has_embed)
+           cpp_error_with_line (pfile, CPP_DL_ERROR, loc, 0,
+                                "unknown embed parameter '%.*s%s%.*s'",
+                                param_prefix_len,
+                                param_prefix
+                                ? (const char *) param_prefix : "",
+                                param_prefix ? "::" : "",
+                                param_name_len, param_name);
+       }
+      if (param_kind != (size_t) -1 && token->type != CPP_OPEN_PAREN)
+       cpp_error_with_line (pfile, CPP_DL_ERROR, loc, 0,
+                            "expected '('");
+      else if (param_kind == 0)
+       {
+         if (params->has_embed && pfile->op_stack == NULL)
+           _cpp_expand_op_stack (pfile);
+         params->limit = _cpp_parse_expr (pfile, "#embed", token);
+         token = _cpp_get_token_no_padding (pfile);
+       }
+      else if (token->type == CPP_OPEN_PAREN)
+       {
+         cpp_embed_params_tokens *save = NULL;
+         auto save_comments = pfile->state.save_comments;
+         switch (param_kind)
+           {
+           case 1: save = &params->prefix; break;
+           case 2: save = &params->suffix; break;
+           case 3: save = &params->if_empty; break;
+           default: break;
+           }
+         if (params->has_embed)
+           save = NULL;
+         else if (save)
+           pfile->state.save_comments = !CPP_OPTION (pfile, discard_comments);
+         skip_balanced_token_seq (pfile, CPP_CLOSE_PAREN, save, false);
+         pfile->state.save_comments = save_comments;
+         token = _cpp_get_token_no_padding (pfile);
+       }
+    }
+  while (1);
+}
+
+/* Handle #embed directive.  */
+
+static void
+do_embed (cpp_reader *pfile)
+{
+  int angle_brackets;
+  struct cpp_embed_params params = {};
+  bool ok;
+  const char *fname = NULL;
+
+  /* Tell the lexer this is an embed directive.  */
+  pfile->state.in_directive = 3;
+
+  if (CPP_OPTION (pfile, traditional))
+    {
+      cpp_error (pfile, CPP_DL_ERROR, /* FIXME should be DL_SORRY */
+                "#embed not supported in traditional C");
+      skip_rest_of_line (pfile);
+      goto done;
+    }
+
+  if (CPP_PEDANTIC (pfile))
+    {
+      if (CPP_OPTION (pfile, cplusplus))
+       cpp_error (pfile, CPP_DL_PEDWARN,
+                  "#%s is a GCC extension", "embed");
+      else if (!CPP_OPTION (pfile, warning_directive))
+       cpp_error (pfile, CPP_DL_PEDWARN,
+                  "#%s before C23 is a GCC extension", "embed");
+    }
+
+  fname = parse_include (pfile, &angle_brackets, NULL, &params.loc);
+  if (!fname)
+    {
+      skip_rest_of_line (pfile);
+      goto done;
+    }
+
+  if (!*fname)
+    {
+      cpp_error_with_line (pfile, CPP_DL_ERROR, params.loc, 0,
+                          "empty filename in #%s",
+                          pfile->directive->name);
+      skip_rest_of_line (pfile);
+      goto done;
+    }
+
+  pfile->state.angled_headers = false;
+  pfile->state.directive_wants_padding = false;
+  ok = _cpp_parse_embed_params (pfile, &params);
+
+  /* Get out of macro context, if we are.  */
+  skip_rest_of_line (pfile);
+
+  if (ok)
+    _cpp_stack_embed (pfile, fname, angle_brackets, &params);
+
+  for (int i = 0; i < 3; ++i)
+    {
+      cpp_embed_params_tokens *p;
+      if (i == 0)
+       p = &params.prefix;
+      else if (i == 1)
+       p = &params.suffix;
+      else
+       p = &params.if_empty;
+      if (p->count == 0)
+       continue;
+      tokenrun *n;
+      for (tokenrun *t = &p->base_run; t; t = n)
+       {
+         n = t->next;
+         XDELETEVEC (t->base);
+         if (t != &p->base_run)
+           XDELETE (t);
+       }
+    }
+
+ done:
+  XDELETEVEC (fname);
+}
+
 /* Subroutine of do_linemarker.  Read possible flags after file name.
    LAST is the last flag seen; 0 if this is the first flag. Return the
    flag if it is valid, 0 at the end of the directive. Otherwise
@@ -2084,7 +2413,7 @@ do_if (cpp_reader *pfile)
   int skip = 1;
 
   if (! pfile->state.skipping)
-    skip = _cpp_parse_expr (pfile, true) == false;
+    skip = _cpp_parse_expr (pfile, "#if", NULL) == false;
 
   push_conditional (pfile, skip, T_IF, pfile->mi_ind_cmacro);
 }
@@ -2172,7 +2501,7 @@ do_elif (cpp_reader *pfile)
       else
        {
          if (pfile->directive == &dtable[T_ELIF])
-           pfile->state.skipping = !_cpp_parse_expr (pfile, false);
+           pfile->state.skipping = !_cpp_parse_expr (pfile, "#elif", NULL);
          else
            {
              cpp_hashnode *node = lex_macro_node (pfile, false);
--- libcpp/expr.cc.jj   2024-06-14 19:44:34.506235942 +0200
+++ libcpp/expr.cc      2024-06-18 08:37:55.793488175 +0200
@@ -1106,6 +1106,9 @@ parse_defined (cpp_reader *pfile)
   const cpp_token *token;
   cpp_context *initial_context = pfile->context;
 
+  if (pfile->state.in_directive == 3)
+    cpp_error (pfile, CPP_DL_ERROR, "'defined' in #embed parameter");
+
   /* Don't expand macros.  */
   pfile->state.prevent_expansion++;
 
@@ -1356,7 +1359,9 @@ static const struct cpp_operator
 };
 
 /* Parse and evaluate a C expression, reading from PFILE.
-   Returns the truth value of the expression.
+   Returns the truth value of the expression if OPEN_PAREN
+   is NULL, otherwise the low 64-bits of the result (when parsing
+   #embed/__has_embed parameters).
 
    The implementation is an operator precedence parser, i.e. a
    bottom-up parser, using a stack for not-yet-reduced tokens.
@@ -1366,8 +1371,9 @@ static const struct cpp_operator
    recently pushed operator is 'top->op'.  An operand (value) is
    stored in the 'value' field of the stack element of the operator
    that precedes it.  */
-bool
-_cpp_parse_expr (cpp_reader *pfile, bool is_if)
+cpp_num_part
+_cpp_parse_expr (cpp_reader *pfile, const char *dir,
+                const cpp_token *open_paren)
 {
   struct op *top = pfile->op_stack;
   unsigned int lex_count;
@@ -1384,6 +1390,14 @@ _cpp_parse_expr (cpp_reader *pfile, bool
   /* Lowest priority operator prevents further reductions.  */
   top->op = CPP_EOF;
 
+  if (pfile->state.in_directive == 3)
+    {
+      ++top;
+      top->op = CPP_OPEN_PAREN;
+      top->token = open_paren;
+      top->loc = open_paren->src_loc;
+    }
+
   for (;;)
     {
       struct op op;
@@ -1454,7 +1468,7 @@ _cpp_parse_expr (cpp_reader *pfile, bool
 
          if (op.op == CPP_EOF && top->op == CPP_EOF)
            SYNTAX_ERROR2_AT (op.loc,
-                             "%s with no expression", is_if ? "#if" : "#elif");
+                             "%s with no expression", dir);
 
          if (top->op != CPP_EOF && top->op != CPP_OPEN_PAREN)
            SYNTAX_ERROR2_AT (op.loc,
@@ -1478,6 +1492,8 @@ _cpp_parse_expr (cpp_reader *pfile, bool
       switch (op.op)
        {
        case CPP_CLOSE_PAREN:
+         if (pfile->state.in_directive == 3 && top == pfile->op_stack)
+           goto embed_done;
          continue;
        case CPP_OR_OR:
          if (!num_zerop (top->value))
@@ -1520,12 +1536,31 @@ _cpp_parse_expr (cpp_reader *pfile, bool
   if (top != pfile->op_stack)
     {
       cpp_error_with_line (pfile, CPP_DL_ICE, top->loc, 0,
-                          "unbalanced stack in %s",
-                          is_if ? "#if" : "#elif");
+                          "unbalanced stack in %s", dir);
     syntax_error:
       return false;  /* Return false on syntax error.  */
     }
 
+  if (pfile->state.in_directive == 3)
+    {
+    embed_done:
+      if (num_zerop (top->value))
+       return 0;
+      if (!top->value.unsignedp
+         && !num_positive (top->value, CPP_OPTION (pfile, precision)))
+       {
+         cpp_error_with_line (pfile, CPP_DL_ERROR, top->loc, 0,
+                              "negative embed parameter operand");
+         return 1;
+       }
+      if (top->value.high)
+       {
+         cpp_error_with_line (pfile, CPP_DL_ERROR, top->loc, 0,
+                              "too large embed parameter operand");
+         return 1;
+       }
+      return top->value.low;
+    }
   return !num_zerop (top->value);
 }
 
@@ -2079,7 +2114,9 @@ num_binary_op (cpp_reader *pfile, cpp_nu
       if (CPP_PEDANTIC (pfile) && (!CPP_OPTION (pfile, c99)
                                   || !pfile->state.skip_eval))
        cpp_pedwarning (pfile, CPP_W_PEDANTIC,
-                       "comma operator in operand of #if");
+                       "comma operator in operand of #%s",
+                       pfile->state.in_directive == 3
+                       ? "embed" : "if");
       lhs = rhs;
       break;
     }
@@ -2215,7 +2252,9 @@ num_div_op (cpp_reader *pfile, cpp_num l
     {
       if (!pfile->state.skip_eval)
        cpp_error_with_line (pfile, CPP_DL_ERROR, location, 0,
-                            "division by zero in #if");
+                            "division by zero in #%s",
+                            pfile->state.in_directive == 3
+                            ? "embed" : "if");
       lhs.unsignedp = unsignedp;
       return lhs;
     }
--- libcpp/files.cc.jj  2024-06-14 19:45:09.954770927 +0200
+++ libcpp/files.cc     2024-06-18 13:07:43.424058433 +0200
@@ -87,6 +87,9 @@ struct _cpp_file
   /* As filled in by stat(2) for the file.  */
   struct stat st;
 
+  /* Size for #embed, perhaps smaller than st.st_size.  */
+  size_t limit;
+
   /* File descriptor.  Invalid if -1, otherwise open.  */
   int fd;
 
@@ -113,6 +116,9 @@ struct _cpp_file
      and error should be emitted if it is included normally.  */
   bool deferred_error : 1;
 
+  /* File loaded from #embed.  */
+  bool embed : 1;
+
   /* > 0: Known C++ Module header unit, <0: known not.  ==0, unknown  */
   int header_unit : 2;
 };
@@ -187,7 +193,8 @@ static const char *dir_name_of_file (_cp
 static void open_file_failed (cpp_reader *pfile, _cpp_file *file, int,
                              location_t);
 static struct cpp_file_hash_entry *search_cache (struct cpp_file_hash_entry 
*head,
-                                            const cpp_dir *start_dir);
+                                                const cpp_dir *start_dir,
+                                                bool is_embed);
 static _cpp_file *make_cpp_file (cpp_dir *, const char *fname);
 static void destroy_cpp_file (_cpp_file *);
 static cpp_dir *make_cpp_dir (cpp_reader *, const char *dir_name, int sysp);
@@ -425,7 +432,7 @@ find_file_in_dir (cpp_reader *pfile, _cp
        }
 
       file->path = path;
-      if (pch_open_file (pfile, file, invalid_pch))
+      if (!file->embed && pch_open_file (pfile, file, invalid_pch))
        return true;
 
       if (open_file (file))
@@ -514,7 +521,9 @@ _cpp_find_file (cpp_reader *pfile, const
   bool invalid_pch = false;
   bool saw_bracket_include = false;
   bool saw_quote_include = false;
+  bool saw_embed_include = false;
   struct cpp_dir *found_in_cache = NULL;
+  bool is_embed = kind == _cpp_FFK_EMBED || kind == _cpp_FFK_HAS_EMBED;
 
   /* Ensure we get no confusion between cached files and directories.  */
   if (start_dir == NULL)
@@ -526,10 +535,12 @@ _cpp_find_file (cpp_reader *pfile, const
 
   /* First check the cache before we resort to memory allocation.  */
   cpp_file_hash_entry *entry
-    = search_cache ((struct cpp_file_hash_entry *) *hash_slot, start_dir);
+    = search_cache ((struct cpp_file_hash_entry *) *hash_slot, start_dir,
+                   is_embed);
   if (entry)
     {
-      if (entry->u.file->deferred_error && kind == _cpp_FFK_NORMAL)
+      if (entry->u.file->deferred_error
+         && (kind == _cpp_FFK_NORMAL || kind == _cpp_FFK_EMBED))
        {
          open_file_failed (pfile, entry->u.file, angle_brackets, loc);
          entry->u.file->deferred_error = false;
@@ -541,6 +552,7 @@ _cpp_find_file (cpp_reader *pfile, const
   file->implicit_preinclude
     = (kind == _cpp_FFK_PRE_INCLUDE
        || (pfile->buffer && pfile->buffer->file->implicit_preinclude));
+  file->embed = is_embed;
 
   if (kind == _cpp_FFK_FAKE)
     file->dont_read = true;
@@ -551,10 +563,17 @@ _cpp_find_file (cpp_reader *pfile, const
        if (find_file_in_dir (pfile, file, &invalid_pch, loc))
          break;
 
-       file->dir = file->dir->next;
+       if (is_embed
+           && file->dir == start_dir
+           && start_dir != pfile->embed_include
+           && start_dir != &pfile->no_search_path)
+         file->dir = pfile->embed_include;
+       else
+         file->dir = file->dir->next;
        if (file->dir == NULL)
          {
-           if (search_path_exhausted (pfile, fname, file))
+           if (!is_embed
+               && search_path_exhausted (pfile, fname, file))
              {
                /* Although this file must not go in the cache,
                   because the file found might depend on things (like
@@ -601,7 +620,7 @@ _cpp_find_file (cpp_reader *pfile, const
                return NULL;
              }
 
-           if (kind != _cpp_FFK_HAS_INCLUDE)
+           if (kind != _cpp_FFK_HAS_INCLUDE && kind != _cpp_FFK_HAS_EMBED)
              open_file_failed (pfile, file, angle_brackets, loc);
            else
              file->deferred_error = true;
@@ -615,11 +634,14 @@ _cpp_find_file (cpp_reader *pfile, const
          saw_bracket_include = true;
        else if (file->dir == pfile->quote_include)
          saw_quote_include = true;
+       else if (file->dir == pfile->embed_include)
+         saw_embed_include = true;
        else
          continue;
 
        entry
-         = search_cache ((struct cpp_file_hash_entry *) *hash_slot, file->dir);
+         = search_cache ((struct cpp_file_hash_entry *) *hash_slot,
+                         file->dir, is_embed);
        if (entry)
          {
            found_in_cache = file->dir;
@@ -673,6 +695,17 @@ _cpp_find_file (cpp_reader *pfile, const
       entry->u.file = file;
       *hash_slot = (void *) entry;
     }
+  if (saw_embed_include
+      && pfile->embed_include != start_dir
+      && found_in_cache != pfile->embed_include)
+    {
+      entry = new_file_hash_entry (pfile);
+      entry->next = (struct cpp_file_hash_entry *) *hash_slot;
+      entry->start_dir = pfile->embed_include;
+      entry->location = loc;
+      entry->u.file = file;
+      *hash_slot = (void *) entry;
+    }
 
   return file;
 }
@@ -761,7 +794,7 @@ read_file_guts (cpp_reader *pfile, _cpp_
 
   if (pfile && regular && total != size && STAT_SIZE_RELIABLE (file->st))
     cpp_error_at (pfile, CPP_DL_WARNING, loc,
-              "%s is shorter than expected", file->path);
+                 "%s is shorter than expected", file->path);
 
   file->buffer = _cpp_convert_input (pfile,
                                     input_charset,
@@ -872,6 +905,9 @@ has_unique_contents (cpp_reader *pfile,
       if (f == file)
        continue; /* It'sa me!  */
 
+      if (f->embed)
+       continue;
+
       if ((import || f->once_only)
          && f->err_no == 0
          && f->st.st_mtime == file->st.st_mtime
@@ -1063,12 +1099,12 @@ search_path_head (cpp_reader *pfile, con
       && file->dir != &pfile->no_search_path)
     dir = file->dir->next;
   else if (angle_brackets)
-    dir = pfile->bracket_include;
+    dir = type == IT_EMBED ? pfile->embed_include : pfile->bracket_include;
   else if (type == IT_CMDLINE)
     /* -include and -imacros use the #include "" chain with the
        preprocessor's cwd prepended.  */
     return make_cpp_dir (pfile, "./", false);
-  else if (pfile->quote_ignores_source_dir)
+  else if (pfile->quote_ignores_source_dir && type != IT_EMBED)
     dir = pfile->quote_include;
   else
     return make_cpp_dir (pfile, dir_name_of_file (file),
@@ -1182,6 +1218,306 @@ cpp_probe_header_unit (cpp_reader *pfile
   return nullptr;
 }
 
+/* Try to load FNAME with #embed/__has_embed parameters PARAMS.
+   If !PARAMS->has_embed, return new token in pfile->directive_result
+   (first token) and rest in a pushed non-macro context.
+   Returns 0 for not found/errors, 1 for non-empty resource and 2
+   for empty resource.  */
+
+int
+_cpp_stack_embed (cpp_reader *pfile, const char *fname, bool angle,
+                 struct cpp_embed_params *params)
+{
+  cpp_dir *dir = search_path_head (pfile, fname, angle, IT_EMBED,
+                                  params->has_embed);
+  if (!dir)
+    return 0;
+  _cpp_file *file = _cpp_find_file (pfile, fname, dir, angle,
+                                   params->has_embed
+                                   ? _cpp_FFK_HAS_EMBED : _cpp_FFK_EMBED,
+                                   params->loc);
+  if (!file)
+    return 0;
+  if (file->dont_read || file->err_no)
+    return 0;
+  _cpp_file *orig_file = file;
+  if (file->buffer_valid
+      && (!S_ISREG (file->st.st_mode)
+         || (file->limit < file->st.st_size + (size_t) 0
+             && file->limit < params->limit)))
+    {
+      bool found = false;
+      if (S_ISREG (file->st.st_mode))
+       {
+         while (file->next_file
+                && file->next_file->embed
+                && file->next_file->buffer_valid
+                && file->next_file->dir == file->dir
+                && strcmp (file->name, file->next_file->name) == 0
+                && strcmp (file->path, file->next_file->path) == 0)
+           {
+             file = file->next_file;
+             if (file->limit >= file->st.st_size + (size_t) 0
+                 || file->limit >= params->limit)
+               {
+                 found = true;
+                 break;
+               }
+           }
+       }
+      if (!found)
+       {
+         _cpp_file *file2 = make_cpp_file (file->dir, file->name);
+         file2->path = xstrdup (file->path);
+         file2->next_file = file->next_file;
+         file2->embed = true;
+         file->next_file = file2;
+         file = file2;
+       }
+    }
+  if (!file->buffer_valid)
+    {
+      if (file->fd == -1 && !open_file (file))
+       {
+         if (params->has_embed)
+           file->deferred_error = true;
+         else
+           open_file_failed (pfile, file, 0, params->loc);
+         return 0;
+       }
+      if (S_ISBLK (file->st.st_mode))
+       {
+         if (params->has_embed)
+           {
+             close (file->fd);
+             file->fd = -1;
+             return 0;
+           }
+         cpp_error_at (pfile, CPP_DL_ERROR, params->loc,
+                       "%s is a block device", file->path);
+       fail:
+         close (file->fd);
+         file->fd = -1;
+         file->dont_read = true;
+         return 0;
+       }
+
+      if (CPP_OPTION (pfile, deps.style)
+         && !params->has_embed
+         && file == orig_file
+         && file->path[0])
+       deps_add_dep (pfile->deps, file->path);
+
+      bool regular = S_ISREG (file->st.st_mode) != 0;
+      ssize_t size, total, count;
+      uchar *buf;
+      if (regular)
+       {
+         cpp_num_part limit;
+         if (file->st.st_size + (cpp_num_part) 0 < params->limit)
+           limit = file->st.st_size;
+         else
+           limit = params->limit;
+         if (params->has_embed)
+           return limit != 0 ? 1 : 2;
+         if (limit > INTTYPE_MAXIMUM (ssize_t))
+           {
+             cpp_error_at (pfile, CPP_DL_ERROR, params->loc,
+                           "%s is too large", file->path);
+             goto fail;
+           }
+         file->limit = limit;
+         size = limit;
+       }
+      else if (params->has_embed)
+       return 2;
+      else if (params->limit > 8 * 1024)
+       size = 8 * 1024;
+      else
+       size = params->limit;
+      buf = XNEWVEC (uchar, size ? size : 1);
+      total = 0;
+
+      while ((count = read (file->fd, buf + total, size - total)) > 0)
+       {
+         total += count;
+         if (total == size)
+           {
+             if (regular || size + (cpp_num_part) 0 == params->limit)
+               break;
+             size = (size_t) size * 2;
+             if (size < 0)
+               {
+                 if (params->limit <= INTTYPE_MAXIMUM (ssize_t))
+                   size = params->limit;
+                 else
+                   {
+                     cpp_error_at (pfile, CPP_DL_ERROR, params->loc,
+                                   "%s is too large", file->path);
+                     free (buf);
+                     goto fail;
+                   }
+               }
+             else if (size + (cpp_num_part) 0 > params->limit)
+               size = params->limit;
+             buf = XRESIZEVEC (uchar, buf, size);
+           }
+       }
+
+      if (count < 0)
+       {
+         cpp_errno_filename (pfile, CPP_DL_ERROR, file->path, params->loc);
+         free (buf);
+         goto fail;
+       }
+
+      if (regular && total != size && STAT_SIZE_RELIABLE (file->st))
+       {
+         cpp_error_at (pfile, CPP_DL_WARNING, params->loc,
+                       "%s is shorter than expected", file->path);
+         file->limit = total;
+       }
+      else if (!regular)
+       file->limit = total;
+
+      file->buffer_start = buf;
+      file->buffer = buf;
+      file->buffer_valid = 1;
+      close (file->fd);
+      file->fd = -1;
+    }
+  else if (params->has_embed)
+    return file->limit && params->limit ? 1 : 2;
+
+  size_t limit = file->limit;
+  if (params->limit < limit)
+    limit = params->limit;
+
+  /* For sizes larger than say 64 bytes, this is just a temporary
+     solution, we should emit a single new token which the FEs will
+     handle as an optimization.  */
+  size_t max = INTTYPE_MAXIMUM (size_t) / sizeof (cpp_token);
+  if (limit > max / 2
+      || (limit
+         ? (params->prefix.count > max
+            || params->suffix.count > max
+            || (limit * 2 + params->prefix.count
+                + params->suffix.count > max))
+         : params->if_empty.count > max))
+    {
+      cpp_error_at (pfile, CPP_DL_ERROR, params->loc,
+                   "%s is too large", file->path);
+      return 0;
+    }
+
+  size_t len = 0;
+  for (size_t i = 0; i < limit; ++i)
+    {
+      if (file->buffer[i] < 10)
+       len += 2;
+      else if (file->buffer[i] < 100)
+       len += 3;
+#if UCHAR_MAX == 255
+      else
+       len += 4;
+#else
+      else if (file->buffer[i] < 1000)
+       len += 4;
+      else
+       {
+         char buf[64];
+         len += sprintf (buf, "%d", file->buffer[i]) + 1;
+       }
+#endif
+      if (len > INTTYPE_MAXIMUM (ssize_t))
+       {
+         cpp_error_at (pfile, CPP_DL_ERROR, params->loc,
+                       "%s is too large", file->path);
+         return 0;
+       }
+    }
+  uchar *s = len ? _cpp_unaligned_alloc (pfile, len) : NULL;
+  _cpp_buff *tok_buff = NULL;
+  cpp_token *toks = NULL, *tok = &pfile->directive_result;
+  size_t count = 0;
+  if (limit)
+    count = (params->prefix.count + limit * 2 - 1
+            + params->suffix.count) - 1;
+  else if (params->if_empty.count)
+    count = params->if_empty.count - 1;
+  if (count)
+    {
+      tok_buff = _cpp_get_buff (pfile, count * sizeof (cpp_token));
+      toks = (cpp_token *) tok_buff->base;
+    }
+  cpp_embed_params_tokens *prefix
+    = limit ? &params->prefix : &params->if_empty;
+  if (prefix->count)
+    {
+      *tok = *prefix->base_run.base;
+      tok = toks;
+      tokenrun *cur_run = &prefix->base_run;
+      while (cur_run)
+       {
+         size_t cnt = (cur_run->next ? cur_run->limit
+                       : prefix->cur_token) - cur_run->base;
+         cpp_token *t = cur_run->base;
+         if (cur_run == &prefix->base_run)
+           {
+             t++;
+             cnt--;
+           }
+         memcpy (tok, t, cnt * sizeof (cpp_token));
+         tok += cnt;
+         cur_run = cur_run->next;
+       }
+    }
+  for (size_t i = 0; i < limit; ++i)
+    {
+      tok->src_loc = params->loc;
+      tok->type = CPP_NUMBER;
+      tok->flags = NO_EXPAND;
+      if (i == 0)
+       tok->flags |= PREV_WHITE;
+      tok->val.str.text = s;
+      tok->val.str.len = sprintf ((char *) s, "%d", file->buffer[i]);
+      s += tok->val.str.len + 1;
+      if (tok == &pfile->directive_result)
+       tok = toks;
+      else
+       tok++;
+      if (i < limit - 1)
+       {
+         tok->src_loc = params->loc;
+         tok->type = CPP_COMMA;
+         tok->flags = NO_EXPAND;
+         tok++;
+       }
+    }
+  if (limit && params->suffix.count)
+    {
+      tokenrun *cur_run = &params->suffix.base_run;
+      cpp_token *orig_tok = tok;
+      while (cur_run)
+       {
+         size_t cnt = (cur_run->next ? cur_run->limit
+                       : params->suffix.cur_token) - cur_run->base;
+         cpp_token *t = cur_run->base;
+         memcpy (tok, t, cnt * sizeof (cpp_token));
+         tok += cnt;
+         cur_run = cur_run->next;
+       }
+      orig_tok->flags |= PREV_WHITE;
+    }
+  pfile->directive_result.flags |= PREV_WHITE;
+  if (count)
+    {
+      _cpp_push_token_context (pfile, NULL, toks, count);
+      pfile->context->buff = tok_buff;
+    }
+  return limit ? 1 : 2;
+}
+
 /* Retrofit the just-entered main file asif it was an include.  This
    will permit correct include_next use, and mark it as a system
    header if that's where it resides.  We use filesystem-appropriate
@@ -1257,9 +1593,11 @@ open_file_failed (cpp_reader *pfile, _cp
 /* Search in the chain beginning at HEAD for a file whose search path
    started at START_DIR != NULL.  */
 static struct cpp_file_hash_entry *
-search_cache (struct cpp_file_hash_entry *head, const cpp_dir *start_dir)
+search_cache (struct cpp_file_hash_entry *head, const cpp_dir *start_dir,
+             bool is_embed)
 {
-  while (head && head->start_dir != start_dir)
+  while (head && (head->start_dir != start_dir
+                 || head->u.file->embed != is_embed))
     head = head->next;
 
   return head;
@@ -1693,21 +2031,24 @@ _cpp_get_file_name (_cpp_file *file)
 struct stat *
 _cpp_get_file_stat (_cpp_file *file)
 {
-    return &file->st;
+  return &file->st;
 }
 
 /* Set the include chain for "" to QUOTE, for <> to BRACKET.  If
    QUOTE_IGNORES_SOURCE_DIR, then "" includes do not look in the
    directory of the including file.
 
-   If BRACKET does not lie in the QUOTE chain, it is set to QUOTE.  */
+   If BRACKET does not lie in the QUOTE chain, it is set to QUOTE.
+
+   EMBED is include chain for #embed <>.  */
 void
 cpp_set_include_chains (cpp_reader *pfile, cpp_dir *quote, cpp_dir *bracket,
-                       int quote_ignores_source_dir)
+                       cpp_dir *embed, int quote_ignores_source_dir)
 {
   pfile->quote_include = quote;
   pfile->bracket_include = quote;
   pfile->quote_ignores_source_dir = quote_ignores_source_dir;
+  pfile->embed_include = embed;
 
   for (; quote; quote = quote->next)
     {
@@ -1716,6 +2057,11 @@ cpp_set_include_chains (cpp_reader *pfil
       if (quote == bracket)
        pfile->bracket_include = bracket;
     }
+  for (; embed; embed = embed->next)
+    {
+      embed->name_map = NULL;
+      embed->len = strlen (embed->name);
+    }
 }
 
 /* Append the file name to the directory to create the path, but don't
--- libcpp/init.cc.jj   2024-06-14 19:45:09.955770914 +0200
+++ libcpp/init.cc      2024-06-18 08:37:55.832487662 +0200
@@ -437,6 +437,7 @@ static const struct builtin_macro builti
   B("__has_builtin",    BT_HAS_BUILTIN,   true),
   B("__has_include",    BT_HAS_INCLUDE,   true),
   B("__has_include_next",BT_HAS_INCLUDE_NEXT,   true),
+  B("__has_embed",      BT_HAS_EMBED, true),
   B("__has_feature",    BT_HAS_FEATURE, true),
   B("__has_extension",  BT_HAS_EXTENSION, true),
   /* Keep builtins not used for -traditional-cpp at the end, and
@@ -623,6 +624,10 @@ cpp_init_builtins (cpp_reader *pfile, in
   else
     _cpp_define_builtin (pfile, "__STDC_HOSTED__ 0");
 
+  _cpp_define_builtin (pfile, "__STDC_EMBED_NOT_FOUND__ 0");
+  _cpp_define_builtin (pfile, "__STDC_EMBED_FOUND__ 1");
+  _cpp_define_builtin (pfile, "__STDC_EMBED_EMPTY__ 2");
+
   if (CPP_OPTION (pfile, objc))
     _cpp_define_builtin (pfile, "__OBJC__ 1");
 }
--- libcpp/lex.cc.jj    2024-06-04 13:19:05.131586037 +0200
+++ libcpp/lex.cc       2024-06-18 14:54:43.291036011 +0200
@@ -5331,7 +5331,20 @@ cpp_directive_only_process (cpp_reader *
                     error messages. */
                  buffer->line_base -= pos - line_start;
 
-                 _cpp_handle_directive (pfile, line_start + 1 != pos);
+                 if (_cpp_handle_directive (pfile, line_start + 1 != pos) == 2)
+                   {
+                     if (pfile->directive_result.type != CPP_PADDING)
+                       cb (pfile, CPP_DO_token, data,
+                           &pfile->directive_result, 
pfile->directive_result.src_loc);
+                     if (pfile->context->prev)
+                       {
+                         gcc_assert (pfile->context->tokens_kind == 
TOKENS_KIND_DIRECT);
+                         for (const cpp_token *tok = FIRST 
(pfile->context).token;
+                              tok != LAST (pfile->context).token; ++tok)
+                           cb (pfile, CPP_DO_token, data, tok, tok->src_loc);
+                         _cpp_pop_context (pfile);
+                       }
+                   }
 
                  /* Sanitize the line settings.  Duplicate #include's can
                     mess things up. */
--- libcpp/macro.cc.jj  2024-06-14 19:44:34.705233331 +0200
+++ libcpp/macro.cc     2024-06-18 15:43:47.496276997 +0200
@@ -371,8 +371,8 @@ unsigned num_macro_tokens_counter = 0;
 
 /* Wrapper around cpp_get_token to skip CPP_PADDING tokens
    and not consume CPP_EOF.  */
-static const cpp_token *
-cpp_get_token_no_padding (cpp_reader *pfile)
+const cpp_token *
+_cpp_get_token_no_padding (cpp_reader *pfile)
 {
   for (;;)
     {
@@ -385,32 +385,32 @@ cpp_get_token_no_padding (cpp_reader *pf
     }
 }
 
-/* Handle meeting "__has_include" builtin macro.  */
+/* Helper function for builtin_has_include and builtin_has_embed.  */
 
-static int
-builtin_has_include (cpp_reader *pfile, cpp_hashnode *op, bool has_next)
+static char *
+builtin_has_include_1 (cpp_reader *pfile, const char *name, bool *paren,
+                      bool *bracket, location_t *loc)
 {
-  int result = 0;
-
   if (!pfile->state.in_directive)
     cpp_error (pfile, CPP_DL_ERROR,
-              "\"%s\" used outside of preprocessing directive",
-              NODE_NAME (op));
+              "\"%s\" used outside of preprocessing directive", name);
 
   pfile->state.angled_headers = true;
   const auto sav_padding = pfile->state.directive_wants_padding;
   pfile->state.directive_wants_padding = true;
-  const cpp_token *token = cpp_get_token_no_padding (pfile);
-  bool paren = token->type == CPP_OPEN_PAREN;
-  if (paren)
-    token = cpp_get_token_no_padding (pfile);
+  const cpp_token *token = _cpp_get_token_no_padding (pfile);
+  *paren = token->type == CPP_OPEN_PAREN;
+  if (*paren)
+    token = _cpp_get_token_no_padding (pfile);
   else
     cpp_error (pfile, CPP_DL_ERROR,
-              "missing '(' before \"%s\" operand", NODE_NAME (op));
+              "missing '(' before \"%s\" operand", name);
   pfile->state.angled_headers = false;
   pfile->state.directive_wants_padding = sav_padding;
 
-  bool bracket = token->type != CPP_STRING;
+  if (loc)
+    *loc = token->src_loc;
+  *bracket = token->type != CPP_STRING;
   char *fname = NULL;
   if (token->type == CPP_STRING || token->type == CPP_HEADER_NAME)
     {
@@ -422,7 +422,19 @@ builtin_has_include (cpp_reader *pfile,
     fname = _cpp_bracket_include (pfile);
   else
     cpp_error (pfile, CPP_DL_ERROR,
-              "operator \"%s\" requires a header-name", NODE_NAME (op));
+              "operator \"%s\" requires a header-name", name);
+  return fname;
+}
+
+/* Handle meeting "__has_include" builtin macro.  */
+
+static int
+builtin_has_include (cpp_reader *pfile, cpp_hashnode *op, bool has_next)
+{
+  int result = 0;
+  bool paren, bracket;
+  char *fname = builtin_has_include_1 (pfile, (const char *) NODE_NAME (op),
+                                      &paren, &bracket, NULL);
 
   if (fname)
     {
@@ -437,13 +449,70 @@ builtin_has_include (cpp_reader *pfile,
     }
 
   if (paren
-      && cpp_get_token_no_padding (pfile)->type != CPP_CLOSE_PAREN)
+      && _cpp_get_token_no_padding (pfile)->type != CPP_CLOSE_PAREN)
     cpp_error (pfile, CPP_DL_ERROR,
               "missing ')' after \"%s\" operand", NODE_NAME (op));
 
   return result;
 }
 
+/* Handle the "__has_embed" expression.  */
+
+static int
+builtin_has_embed (cpp_reader *pfile)
+{
+  int result = 0;
+  bool paren, bracket;
+  struct cpp_embed_params params = {};
+  char *fname = builtin_has_include_1 (pfile, "__has_embed", &paren,
+                                      &bracket, &params.loc);
+
+  if (fname)
+    {
+      params.has_embed = true;
+      auto save_in_directive = pfile->state.in_directive;
+      auto save_angled_headers = pfile->state.angled_headers;
+      auto save_directive_wants_padding = pfile->state.directive_wants_padding;
+      auto save_op_stack = pfile->op_stack;
+      auto save_op_limit = pfile->op_limit;
+      auto save_skip_eval = pfile->state.skip_eval;
+      auto save_mi_ind_cmacro = pfile->mi_ind_cmacro;
+      /* Tell the lexer this is an embed directive.  */
+      pfile->state.in_directive = 3;
+      pfile->state.angled_headers = false;
+      pfile->state.directive_wants_padding = false;
+      pfile->op_stack = NULL;
+      pfile->op_limit = NULL;
+      bool ok = _cpp_parse_embed_params (pfile, &params);
+      free (pfile->op_stack);
+      pfile->state.in_directive = save_in_directive;
+      pfile->state.angled_headers = save_angled_headers;
+      pfile->state.directive_wants_padding = save_directive_wants_padding;
+      pfile->op_stack = save_op_stack;
+      pfile->op_limit = save_op_limit;
+      pfile->state.skip_eval = save_skip_eval;
+      pfile->mi_ind_cmacro = save_mi_ind_cmacro;
+
+      if (!*fname)
+       {
+         cpp_error_with_line (pfile, CPP_DL_ERROR, params.loc, 0,
+                              "empty filename in '%s'", "__has_embed");
+         ok = false;
+       }
+
+      /* Do not do the lookup if we're skipping, that's unnecessary
+        IO.  */
+      if (ok && !pfile->state.skip_eval)
+       result = _cpp_stack_embed (pfile, fname, bracket, &params);
+
+      XDELETEVEC (fname);
+    }
+  else if (paren)
+    _cpp_get_token_no_padding (pfile);
+
+  return result;
+}
+
 /* Emits a warning if NODE is a macro defined in the main file that
    has not been used.  */
 int
@@ -681,6 +750,16 @@ _cpp_builtin_macro_text (cpp_reader *pfi
                                    node->value.builtin == BT_HAS_INCLUDE_NEXT);
       break;
 
+    case BT_HAS_EMBED:
+      if (CPP_OPTION (pfile, traditional))
+       {
+         cpp_error (pfile, CPP_DL_ERROR, /* FIXME should be DL_SORRY */
+                    "'__has_embed' not supported in traditional C");
+         break;
+       }
+      number = builtin_has_embed (pfile);
+      break;
+
     case BT_HAS_FEATURE:
     case BT_HAS_EXTENSION:
       number = pfile->cb.has_feature (pfile,
--- gcc/doc/cppdiropts.texi.jj  2024-06-14 19:44:34.132240848 +0200
+++ gcc/doc/cppdiropts.texi     2024-06-18 08:37:55.880487032 +0200
@@ -152,3 +152,12 @@ Do not search for header files in the C+
 but do still search the other standard directories.  (This option is
 used when building the C++ library.)
 
+@opindex embed-dir
+@item --embed-dir=@var{dir}
+Append @var{dir} directory to the list of searched directories for
+@code{#embed} preprocessing directive or @code{__has_embed} macro.
+There are no default directories for @code{#embed}.
+
+If @var{dir} begins with @samp{=} or @code{$SYSROOT}, then the @samp{=}
+or @code{$SYSROOT} is replaced by the sysroot prefix; see
+@option{--sysroot} and @option{-isysroot}.
--- gcc/doc/cpp.texi.jj 2024-06-14 19:45:08.063795733 +0200
+++ gcc/doc/cpp.texi    2024-06-18 16:56:16.586467116 +0200
@@ -82,6 +82,7 @@ useful on its own.
 * Diagnostics::
 * Line Control::
 * Pragmas::
+* Binary Resource Inclusion:
 * Other Directives::
 * Preprocessor Output::
 * Traditional Mode::
@@ -3204,6 +3205,7 @@ directive}: @samp{#if}, @samp{#ifdef} or
 * @code{__has_feature}::
 * @code{__has_extension}::
 * @code{__has_include}::
+* @code{__has_embed}::
 @end menu
 
 @node Ifdef
@@ -3643,6 +3645,36 @@ but not with others that don't.
 #endif
 @end smallexample
 
+@node @code{__has_embed}
+@subsection @code{__has_embed}
+@cindex @code{__has_embed}
+
+The special operator @code{__has_embed (@var{operands})} may be used in
+@samp{#if} and @samp{#elif} expressions to test whether a binary resource
+specified by the first operand with optional @samp{#embed} parameters can
+be included using the @samp{#embed} directive (@pxref{Binary Resource
+Inclusion}) with the same parameters.  The operator returns
+@code{__STDC_EMBED_NOT_FOUND__} if either the binary resource does not exist
+or at least one of the parameters is not supported by the implementation,
+@code{__STDC_EMBED_FOUND__} if all the parameters are supported and the
+resource is not empty and finally @code{__STDC_EMBED_EMPTY__} if all the
+parameters are supported and the resource is empty.
+The support of @code{__has_embed} operator can be tested with @samp{#ifdef}
+etc. similarly to @code{__has_include} and the same rules on how to
+test it apply.  @code{__FILE__} can be often used to test if an
+implementation supports some implementation defined parameter, e.g.@:
+
+@smallexample
+#ifdef __has_embed
+#if __has_embed (__FILE__ limit (4) myvendor::myattr (42)) != 
__STDC_EMBED_NOT_FOUND__
+#embed "foo.dat" limit (4) myvendor::myattr (42)
+#endif
+#endif
+@end smallexample
+
+The @code{__has_embed} operator is not supported in the Traditional Mode
+(@pxref{Traditional Mode}).
+
 @node Deleted Code
 @section Deleted Code
 @cindex commenting out code
@@ -3893,6 +3925,61 @@ These pragmas are accepted, but have no
 
 @end ftable
 
+@node Binary Resource Inclusion
+@chapter Binary Resource Inclusion
+
+@cindex embed directive
+
+The @samp{#embed} directive as specified in the C23 standard allows
+efficient inclusion of binary data, usually in initializers of arrays.
+GCC supports this directive in C23 mode and as an extension in older C
+versions and in C++.
+
+Similarly to the @samp{#include} directive (@pxref{Include Syntax})
+the first argument of the directive is a filename in the same forms
+as @samp{#include}.
+
+@table @code
+@item #embed <@var{file}>
+If @var{file} is an absolute filename, this includes the mentioned
+file, otherwise searches it in directories specified by the
+@option{--embed-dir=} command line option for the @var{file}.
+
+@item #embed "@var{file}"
+This variant searches @var{file} in the same directory as the source
+file which uses the @code{#embed} directive and only if not found there
+continues searching directories specified by the @option{--embed-dir=}
+command line option.
+@end table
+
+The @code{#embed} directive is expanded as if it was a sequence of
+integer literals from 0 to @code{UCHAR_MAX} separated by commas, e.g.@:
+@code{#embed __FILE__ limit(4)}
+could act as if it expanded to
+@code{35,101,109,98}.  No character set conversion is performed.
+
+Optional embed parameters can be specified after the required filename
+argument.  There are either standard attributes, specified by an
+identifier or identifier prefixed and suffixed by 2 underscores (both
+treated the same), followed by parameter argument in parentheses, like
+@code{#embed "foo.dat" limit(1) __prefix__(32, ) suffix(, 0)}
+with currently supported standard parameters @code{limit}, @code{prefix},
+@code{suffix} and @code{if_empty}, or implementation defined parameters
+specified by a unique vendor prefix followed by @code{::} followed by
+name of the parameter.  GCC will use the @code{gnu} prefix but currently
+doesn't support any extensions.
+
+The @code{limit} parameter argument is a constant expression which
+specifies the maximum number of bytes included by the directive,
+@code{prefix} and @code{suffix} arguments are balanced token sequences
+which are prepended and appended to the integer literal sequence if
+that sequence is not empty and @code{if_empty} argument is balanced token
+sequence which is used as expansion for @code{#embed} directive if the
+resource is empty.
+
+The @code{#embed} directive is not supported in the Traditional Mode
+(@pxref{Traditional Mode}).
+
 @node Other Directives
 @chapter Other Directives
 
--- gcc/doc/invoke.texi.jj      2024-06-14 19:45:08.123794946 +0200
+++ gcc/doc/invoke.texi 2024-06-18 08:37:55.930486375 +0200
@@ -717,6 +717,7 @@ Objective-C and Objective-C++ Dialects}.
 -iplugindir=@var{dir}  -iprefix @var{file}
 -iquote @var{dir}  -isysroot @var{dir}  -isystem @var{dir}
 -iwithprefix @var{dir}  -iwithprefixbefore @var{dir}
+--embed-dir=@var{dir}
 -L@var{dir}  -no-canonical-prefixes  --no-sysroot-suffix
 -nostdinc  -nostdinc++  --sysroot=@var{dir}}
 
--- gcc/gcc.cc.jj       2024-06-14 19:44:34.267239077 +0200
+++ gcc/gcc.cc  2024-06-18 08:37:55.934486323 +0200
@@ -1248,7 +1248,7 @@ static const char *cpp_unique_options =
  %{remap} %{%:debug-level-gt(2):-dD}\
  %{!iplugindir*:%{fplugin*:%:find-plugindir()}}\
  %{H} %C %{D*&U*&A*} %{i*} %Z %i\
- %{E|M|MM:%W{o*}}\
+ %{E|M|MM:%W{o*}} %{-embed*}\
  
%{fdeps-format=*:%{!fdeps-file=*:-fdeps-file=%:join(%{!o:%b.ddi}%{o*:%.ddi%*})}}\
  
%{fdeps-format=*:%{!fdeps-target=*:-fdeps-target=%:join(%{!o:%b.o}%{o*:%.o%*})}}";
 
--- gcc/genmatch.cc.jj  2024-06-14 19:44:34.306238566 +0200
+++ gcc/genmatch.cc     2024-06-18 08:37:55.935486309 +0200
@@ -5634,7 +5634,7 @@ main (int argc, char **argv)
   dir->name = getpwd ();
   if (!dir->name)
     dir->name = ASTRDUP (".");
-  cpp_set_include_chains (r, dir, NULL, false);
+  cpp_set_include_chains (r, dir, NULL, NULL, false);
 
   if (!cpp_read_main_file (r, input))
     return 1;
--- gcc/incpath.h.jj    2024-06-14 19:44:34.367237765 +0200
+++ gcc/incpath.h       2024-06-18 08:37:55.935486309 +0200
@@ -24,6 +24,7 @@ enum incpath_kind {
   INC_BRACKET,   /* include <foo> */
   INC_SYSTEM,    /* sys-include */
   INC_AFTER,    /* post-sysinclude  */
+  INC_EMBED,     /* embed <foo> */
   INC_MAX
 };
 
--- gcc/incpath.cc.jj   2024-06-14 19:44:34.343238080 +0200
+++ gcc/incpath.cc      2024-06-18 08:37:55.936486296 +0200
@@ -360,6 +360,7 @@ merge_include_chains (const char *sysroo
       add_sysroot_to_chain (sysroot, INC_BRACKET);
       add_sysroot_to_chain (sysroot, INC_SYSTEM);
       add_sysroot_to_chain (sysroot, INC_AFTER);
+      add_sysroot_to_chain (sysroot, INC_EMBED);
     }
 
   /* Join the SYSTEM and AFTER chains.  Remove duplicates in the
@@ -383,6 +384,10 @@ merge_include_chains (const char *sysroo
     = remove_duplicates (pfile, heads[INC_QUOTE], heads[INC_SYSTEM],
                         heads[INC_BRACKET], verbose);
 
+  /* Remove duplicates from EMBED that are in itself.  */
+  heads[INC_EMBED]
+    = remove_duplicates (pfile, heads[INC_EMBED], 0, 0, verbose);
+
   /* If verbose, print the list of dirs to search.  */
   if (verbose)
     {
@@ -398,6 +403,13 @@ merge_include_chains (const char *sysroo
          fprintf (stderr, " %s\n", p->name);
        }
       fprintf (stderr, _("End of search list.\n"));
+      if (heads[INC_EMBED])
+       {
+         fprintf (stderr, _("#embed <...> search starts here:\n"));
+         for (p = heads[INC_EMBED]; p; p = p->next)
+           fprintf (stderr, " %s\n", p->name);
+         fprintf (stderr, _("End of #embed search list.\n"));
+       }
     }
 }
 
@@ -506,7 +518,7 @@ register_include_chains (cpp_reader *pfi
   merge_include_chains (sysroot, pfile, verbose);
 
   cpp_set_include_chains (pfile, heads[INC_QUOTE], heads[INC_BRACKET],
-                         quote_ignores_source_dir);
+                         heads[INC_EMBED], quote_ignores_source_dir);
 }
 
 /* Return the current chain of cpp dirs.  */
--- gcc/c-family/c.opt.jj       2024-06-14 19:45:07.376804745 +0200
+++ gcc/c-family/c.opt  2024-06-18 08:37:55.956486034 +0200
@@ -66,6 +66,10 @@ C ObjC C++ ObjC++ Separate Alias(d)
 -dump=
 C ObjC C++ ObjC++ Joined Alias(d)
 
+-embed-dir=
+C ObjC C++ ObjC++ Joined MissingArgError(missing filename after %qs)
+--embed-dir=<dir>      Add <dir> to the #embed path.
+
 -imacros
 C ObjC C++ ObjC++ Separate Alias(imacros) MissingArgError(missing filename 
after %qs)
 
--- gcc/c-family/c-opts.cc.jj   2024-06-14 19:45:07.374804771 +0200
+++ gcc/c-family/c-opts.cc      2024-06-18 08:37:55.957486021 +0200
@@ -623,6 +623,10 @@ c_common_handle_option (size_t scode, co
       add_prefixed_path (arg, INC_BRACKET);
       break;
 
+    case OPT__embed_dir_:
+      add_path (xstrdup (arg), INC_EMBED, 0, true);
+      break;
+
     case OPT_lang_asm:
       cpp_set_lang (parse_in, CLK_ASM);
       cpp_opts->dollars_in_ident = false;
--- gcc/testsuite/c-c++-common/cpp/embed-1.c.jj 2024-06-18 08:37:55.958486007 
+0200
+++ gcc/testsuite/c-c++-common/cpp/embed-1.c    2024-06-18 08:37:55.958486007 
+0200
@@ -0,0 +1,333 @@
+/* { dg-do run } */
+/* { dg-options "--embed-dir=${srcdir}/c-c++-common/cpp/embed-dir" } */
+/* { dg-additional-options "-std=gnu99" { target c } } */
+
+#if !defined(__STDC_EMBED_NOT_FOUND__) || __STDC_EMBED_NOT_FOUND__ != 0
+#error "__STDC_EMBED_NOT_FOUND__ not defined or has invalid value"
+#endif
+
+#if __STDC_EMBED_FOUND__ != 1
+#error "__STDC_EMBED_FOUND__ not defined or has invalid value"
+#endif
+
+#if __STDC_EMBED_EMPTY__ != 2
+#error "__STDC_EMBED_EMPTY__ not defined or has invalid value"
+#endif
+
+#ifndef __has_embed
+#error "__has_embed not defined"
+#endif
+
+#if __has_embed (__FILE__) != __STDC_EMBED_FOUND__
+#error "__has_embed fail"
+#endif
+
+#if __has_embed (__FILE__ limit (NONEXISTENT_MACRO) prefix (1 2 3) __suffix__ 
() if_empty ({})) != __STDC_EMBED_EMPTY__
+#error "__has_embed fail"
+#endif
+
+#if __has_embed (__FILE__ __limit__ (1) __prefix__ () suffix (1 / 0) 
__if_empty__ ((({{[0[0{0{0(0(0)1)1}1}]]}})))) != __STDC_EMBED_FOUND__
+#error "__has_embed fail"
+#endif
+
+#if __has_embed (__FILE__ limit (0) gnu::nonexistent ({})) != 
__STDC_EMBED_NOT_FOUND__
+#error "__has_embed fail"
+#endif
+
+#if __has_embed (__FILE__ limit (0) __gnu__::__non_existent__ ({})) != 
__STDC_EMBED_NOT_FOUND__
+#error "__has_embed fail"
+#endif
+
+#if __has_embed (__FILE__ limit (0) gnu::__non_existent__ ({})) != 
__STDC_EMBED_NOT_FOUND__
+#error "__has_embed fail"
+#endif
+
+#if __has_embed (__FILE__ limit (0) non_existent_standard_arg (42)) != 
__STDC_EMBED_NOT_FOUND__
+#error "__has_embed fail"
+#endif
+
+#if __has_embed ("non-existent-file" limit (NONEXISTENT_MACRO + 1)) != 
__STDC_EMBED_NOT_FOUND__
+#error "__has_embed fail"
+#endif
+
+#if __has_embed ("embed-1.c" limit (0)) != __STDC_EMBED_EMPTY__
+#errror "__has_embed fail"
+#endif
+
+#define E1 "embed-1.c"
+#define E2 limit (
+#define E3 1)
+#if __has_embed (E1 E2 E3) != __STDC_EMBED_FOUND__
+#errror "__has_embed fail"
+#endif
+
+#if __has_embed (<embed-1.c>) != __STDC_EMBED_NOT_FOUND__
+#error "__has_embed fail"
+#endif
+
+#define E4 <embed-1.c>
+#define E5 limit
+#define E6 1)
+#if __has_embed ( \
+E4 \
+E5 ( \
+E6 \
+) != __STDC_EMBED_NOT_FOUND__
+#error "__has_embed fail"
+#endif
+
+#if __has_embed ("embed-1.inc") != __STDC_EMBED_FOUND__
+#errror "__has_embed fail"
+#endif
+
+#if __has_embed ( "embed-1.inc" __limit__ ( 7 - 7 ) ) != __STDC_EMBED_EMPTY__
+#errror "__has_embed fail"
+#endif
+
+#if __has_embed (<embed-1.inc>) != __STDC_EMBED_FOUND__
+#errror "__has_embed fail"
+#endif
+
+#if __has_embed (<embed-1.inc> limit(0)) != __STDC_EMBED_EMPTY__
+#errror "__has_embed fail"
+#endif
+
+#if __has_embed ("../empty.h") != __STDC_EMBED_EMPTY__
+#error "__has_embed fail"
+#endif
+
+#if __has_embed (<../empty.h>) != __STDC_EMBED_NOT_FOUND__
+#error "__has_embed fail"
+#endif
+
+#if __has_embed ("../../empty.h") != __STDC_EMBED_EMPTY__
+#error "__has_embed fail"
+#endif
+
+#if __has_embed (<../../empty.h>) != __STDC_EMBED_EMPTY__
+#error "__has_embed fail"
+#endif
+
+#if __has_embed ("../empty.h" __limit__ (42)) !=  __STDC_EMBED_EMPTY__
+#error "__has_embed fail"
+#endif
+
+#if __has_embed (<../empty.h> __limit__ (42)) !=  __STDC_EMBED_NOT_FOUND__
+#error "__has_embed fail"
+#endif
+
+#if __has_embed ("../../empty.h" limit (42)) !=  __STDC_EMBED_EMPTY__
+#error "__has_embed fail"
+#endif
+
+#if __has_embed (<../../empty.h> __limit__ (42)) !=  __STDC_EMBED_EMPTY__
+#error "__has_embed fail"
+#endif
+
+#if 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 + \
+    __has_embed (<magna-carta.txt> limit (17 + (16 + (15 + (14 + (13 \
+    + 12))))))))))))))))))))))))))))))) != 27 * 26 / 2 + __STDC_EMBED_FOUND__
+#error "__has_embed fail"
+#endif
+
+#if 0
+#if __has_embed (<non-existent-file.bin> limit (1 + 2 + 3 + 4)) != 42
+#error "__has_embed fail"
+#endif
+#endif
+
+#if (0 && __has_embed (<non-existent-file.bin> limit (3))) != 0
+#error "fail"
+#endif
+
+#if __STDC_VERSION__ >= 202311L || __cplusplus >= 201103L
+static_assert (
+#embed <embed-1.inc>
+== 'a', "");
+static_assert (
+#embed "embed-1.inc" \
+__limit__ (\
+0) __if_empty__ (42) __prefix__ ( \
+256 + ) __suffix__ (+ 17)
+== 42, "");
+static_assert (
+#embed "embed-1.inc" limit (42) if_empty (42) prefix (256 + ) suffix (+ 17)
+== 256 + 'a' + 17, "");
+#endif
+
+int a =
+#embed __FILE__ limit (1)
+;
+int b =
+#embed __FILE__ if_empty (42; int c = 0) limit (0)
+;
+const unsigned char magna_carta[] = {
+#embed <magna-carta.txt> prefix (/* This is a prefix */) suffix (, 0) if_empty 
(0)
+};
+const unsigned char d[] = {
+#define MAGNA_CARTA "magna-carta.txt"
+#define MAGNA_CARTA_PARAMS prefix (239, 187, 191,) \
+suffix (, 0) limit (15)
+#embed MAGNA_CARTA MAGNA_CARTA_PARAMS \
+\
+if_empty (0{1[2[3{4(5(6)7)8}9]0]1}2)
+};
+#ifndef __cplusplus
+const unsigned char e[] = {
+#embed MAGNA_CARTA __limit__ (42) __suffix__ (, [21] = 'X', [22] = 'X', [23] = 
'X')
+};
+#endif
+int f;
+struct S { int a; long b; unsigned short c; long long d; } g = {
+#embed "magna-carta.txt" limit (4)
+};
+const unsigned char h[] = {
+#embed __FILE__ suffix (, 0)
+};
+struct T { int a; };
+struct U { unsigned short a; struct T b; long long c; };
+struct V { unsigned long long a; struct U b; short int c; int d; };
+struct V v = {
+#embed "magna-carta.txt" __limit__(4)__prefix__(42,)__suffix__(,-42)
+};
+#ifndef __cplusplus
+const unsigned char w[] = {
+#embed <magna-carta.txt> prefix([0] = 42, [72] =) limit(1500)
+};
+#endif
+const unsigned char x[] = {
+#define XIFEMPTY1 0, 1
+#define XIFEMPTY2 ,3,
+#define XIFEMPTY3 4
+#embed "../empty.h" if_empty (XIFEMPTY1,2 XIFEMPTY2 \
+XIFEMPTY3) prefix (5, 6, 7, ) suffix (, 8, 9)
+};
+const unsigned char y[] = {
+#embed <embed-3.c> suffix(,0)
+};
+const unsigned char z[] = {
+#embed "embed-3.c" suffix(,0)
+};
+
+#if 0
+#embed <non-existent-file.bin> limit (3)
+#endif
+
+#ifdef __cplusplus
+#define C "C"
+#else
+#define C
+#endif
+extern C void abort (void);
+#ifdef __cplusplus
+extern C const char *strstr (const char *, const char *);
+#else
+extern C char *strstr (const char *, const char *);
+#endif
+
+void
+foo (unsigned int a, unsigned long long b, unsigned char c, int d, int e)
+{
+  if (a != 'H' || b != 'e' || c != 'n' || d != 'r' || !e)
+    abort ();
+}
+
+int
+main ()
+{
+  if (a != '/' || b != 42 || c != 0)
+    abort ();
+  if (sizeof (magna_carta) != 17893 + 1
+      /* Allow for DOS line endings instead of Unix just in case.  */
+      && sizeof (magna_carta) != 17939 + 1)
+    abort ();
+  if (!strstr ((const char *) magna_carta, "imprisonétur"))
+    abort ();
+  if (sizeof (d) != 3 + 15 + 1
+      || d[0] != 239 || d[1] != 187 || d[2] != 191 || d[3 + 15] != 0)
+    abort ();
+#ifndef __cplusplus
+  if (sizeof (e) != 42 || e[21] != 'X' || e[22] != 'X' || e[23] != 'X')
+    abort ();
+#endif
+  f = (
+#embed "magna-carta.txt" limit (4) prefix (172 + ) suffix (+ 2)
+  );
+  if (f != 'r' + 2)
+    abort ();
+  if (g.a != 'H' || g.b != 'e' || g.c != 'n' || g.d != 'r')
+    abort ();
+  if (!strstr ((const char *) h, "imprisonétur")
+      || !strstr ((const char *) h, "blah blah"))
+    abort ();
+  if (v.a != 42 || v.b.a != 'H' || v.b.b.a != 'e'
+      || v.b.c != 'n' || v.c != 'r' || v.d != -42)
+    abort ();
+#ifndef __cplusplus
+  if (sizeof (w) != 1572 || w[0] != 42 || w[1] != 0 || w[71] != 0
+      || w[72] != 'H' || w[73] != 'e' || w[74] != 'n' || w[75] != 'r')
+    abort ();
+#endif
+  if (sizeof (x) != 5 || x[0] != 0 || x[1] != 1 || x[2] != 2
+      || x[3] != 3 || x[4] != 4)
+    abort ();
+  foo (
+#embed <magna-carta.txt> limit(5)
+  );
+  if (sizeof (y) > 100
+      || !strstr ((const char *) y, "Dummy file.")
+      || strstr ((const char *) y, "__gnu__::__non_existent_parameter"))
+    abort ();
+  if (sizeof (z) < 100
+      || strstr ((const char *) z, "Dummy file.")
+      || !strstr ((const char *) z, "__gnu__::__non_existent_parameter"))
+    abort ();
+  if (sizeof (
+#embed "embed-1.inc"
+      ) != sizeof (int))
+    abort ();
+#ifndef __cplusplus
+  if (_Generic (
+#embed "embed-1.inc" __limit__ (1) __suffix__ (, int: 42, default: 0)
+      ) != 42)
+    abort ();
+#endif
+#if __STDC_VERSION__ >= 202311L
+  typeof (
+#embed "embed-1.inc" limit (1)
+  ) j;
+  if (sizeof (j) != sizeof (int))
+    abort ();
+#elif __cplusplus >= 201103L
+  decltype (
+#embed "embed-1.inc" limit (1)
+  ) j;
+  if (sizeof (j) != sizeof (int))
+    abort ();
+#endif
+#if __has_embed ("embed-5.c" ds9000::element_type(short))
+  short meow[] = {
+    #embed "embed-5.c" ds9000::element_type(short)
+  };
+#elif __has_embed ("embed-5.c")
+  const unsigned char meow_bytes[] = {
+    #embed "embed-5.c"
+  };
+  short meow[sizeof (meow_bytes) / sizeof (short)] = {};
+  for (int i = 0; i < (int) (sizeof (meow) / sizeof (short)); i++)
+    meow[i] = (meow_bytes[i * 2] << 8) | meow_bytes[i * 2 + 1];
+#else
+  #error "cannot find embed-5.c resource"
+#endif
+  if (meow[0] != ('/' << 8) + '*')
+    abort ();
+#if __has_embed("././././embed-1.c" __limit__(1))
+  if (
+               #embed          "././././embed-1.c" /* This */ limit /* is */ ( 
/* a */ 1 /*comment*/) // .
+      != '/')
+    abort ();
+#else
+#error "__has_embed fail"
+#endif
+}
--- gcc/testsuite/c-c++-common/cpp/embed-2.c.jj 2024-06-18 08:37:55.958486007 
+0200
+++ gcc/testsuite/c-c++-common/cpp/embed-2.c    2024-06-18 08:37:55.958486007 
+0200
@@ -0,0 +1,5 @@
+/* { dg-do run } */
+/* { dg-options "--embed-dir=${srcdir}/c-c++-common/cpp/embed-dir -save-temps" 
} */
+/* { dg-additional-options "-std=gnu99" { target c } } */
+
+#include "embed-1.c"
--- gcc/testsuite/c-c++-common/cpp/embed-3.c.jj 2024-06-18 08:37:55.958486007 
+0200
+++ gcc/testsuite/c-c++-common/cpp/embed-3.c    2024-06-18 08:37:55.958486007 
+0200
@@ -0,0 +1,83 @@
+/* { dg-do preprocess } */
+/* { dg-options "" } */
+
+#embed __FILE__ , limit(1) /* { dg-error "expected parameter name" } */
+#embed __FILE__ limit(1)) /* { dg-error "expected parameter name" } */
+#embed __FILE__ limit(1) limit(1) /* { dg-error "duplicate embed parameter 
'limit'" } */
+#embed __FILE__ limit(1) prefix() prefix() /* { dg-error "duplicate embed 
parameter 'prefix'" } */
+#embed __FILE__ limit(1) suffix(1 2 3) __suffix__() /* { dg-error "duplicate 
embed parameter 'suffix'" } */
+#embed __FILE__ if_empty ("this") if_empty("that") limit(1) /* { dg-error 
"duplicate embed parameter 'if_empty'" } */
+#embed __FILE__ non_existent_parameter (42) limit(1) /* { dg-error "unknown 
embed parameter 'non_existent_parameter'" } */
+#embed __FILE__ limit(1) gnu::non_existent_parameter /* { dg-error "unknown 
embed parameter 'gnu::non_existent_parameter'" } */
+#embed __FILE__ limit(1) __gnu__::__non_existent_parameter /* { dg-error 
"unknown embed parameter 'gnu::__non_existent_parameter'" } */
+#embed __FILE__ limit(1) gnu__::__non_existent_parameter__ /* { dg-error 
"unknown embed parameter 'gnu__::non_existent_parameter'" } */
+#embed __FILE__ limit prefix() suffix() /* { dg-error "expected '\\\('" } */
+#embed __FILE__ __prefix__ suffix() limit(1) /* { dg-error "expected '\\\('" } 
*/
+#embed __FILE__ prefix() suffix limit(1) /* { dg-error "expected '\\\('" } */
+#embed __FILE__ if_empty limit(1) /* { dg-error "expected '\\\('" } */
+#embed __FILE__ limit (1 / 0) /* { dg-error "division by zero in #embed" } */
+#embed __FILE__ limit (+ + +) /* { dg-error "operator '\\\+' has no right 
operand" } */
+#embed __FILE__ limit(1) prefix(() /* { dg-error "unbalanced '\\\('" } */
+#embed __FILE__ limit(1) prefix(({[})]) /* { dg-error "unbalanced '\\\('" } */
+/* { dg-error "unbalanced '\\\)'" "" { target *-*-* } .-1 } */
+/* { dg-error "unbalanced '\\\{'" "" { target *-*-* } .-2 } */
+/* { dg-error "unbalanced '\\\}'" "" { target *-*-* } .-3 } */
+#embed __FILE__ limit(1) prefix(]) /* { dg-error "unbalanced '\\\]'" } */
+#embed __FILE__ limit(1) prefix([) /* { dg-error "unbalanced '\\\)'" } */
+/* { dg-error "unbalanced '\\\['" "" { target *-*-* } .-1 } */
+/* { dg-error "unbalanced '\\\('" "" { target *-*-* } .-2 } */
+#embed __FILE__ limit(1) __suffix__(() /* { dg-error "unbalanced '\\\('" } */
+#embed __FILE__ limit(1) __suffix__(({[})]) /* { dg-error "unbalanced '\\\('" 
} */
+/* { dg-error "unbalanced '\\\)'" "" { target *-*-* } .-1 } */
+/* { dg-error "unbalanced '\\\{'" "" { target *-*-* } .-2 } */
+/* { dg-error "unbalanced '\\\}'" "" { target *-*-* } .-3 } */
+#embed __FILE__ limit(1) suffix([) /* { dg-error "unbalanced '\\\)'" } */
+/* { dg-error "unbalanced '\\\['" "" { target *-*-* } .-1 } */
+/* { dg-error "unbalanced '\\\('" "" { target *-*-* } .-2 } */
+#embed __FILE__ limit(1) if_empty(() /* { dg-error "unbalanced '\\\('" } */
+#embed __FILE__ limit(1) __if_empty__(({[})]) /* { dg-error "unbalanced 
'\\\('" } */
+/* { dg-error "unbalanced '\\\)'" "" { target *-*-* } .-1 } */
+/* { dg-error "unbalanced '\\\{'" "" { target *-*-* } .-2 } */
+/* { dg-error "unbalanced '\\\}'" "" { target *-*-* } .-3 } */
+#embed __FILE__ limit(1) __if_empty__([) /* { dg-error "unbalanced '\\\)'" } */
+/* { dg-error "unbalanced '\\\['" "" { target *-*-* } .-1 } */
+/* { dg-error "unbalanced '\\\('" "" { target *-*-* } .-2 } */
+#embed __FILE__ limit(1) gnu::non_existent_parameter(() /* { dg-error "unknown 
embed parameter 'gnu::non_existent_parameter'" } */
+/* { dg-error "unbalanced '\\\('" "" { target *-*-* } .-1 } */
+#embed __FILE__ limit(1) __gnu__::__non_existent_parameter__(({[})]) /* { 
dg-error "unknown embed parameter 'gnu::non_existent_parameter'" } */
+/* { dg-error "unbalanced '\\\('" "" { target *-*-* } .-1 } */
+/* { dg-error "unbalanced '\\\)'" "" { target *-*-* } .-2 } */
+/* { dg-error "unbalanced '\\\{'" "" { target *-*-* } .-3 } */
+/* { dg-error "unbalanced '\\\}'" "" { target *-*-* } .-4 } */
+#embed __FILE__ limit(1) __gnu__::__non_existent_parameter__([) /* { dg-error 
"unknown embed parameter 'gnu::non_existent_parameter'" } */
+/* { dg-error "unbalanced '\\\)'" "" { target *-*-* } .-1 } */
+/* { dg-error "unbalanced '\\\['" "" { target *-*-* } .-2 } */
+/* { dg-error "unbalanced '\\\('" "" { target *-*-* } .-3 } */
+#embed limit(1) /* { dg-error "#embed expects \\\"FILENAME\\\" or <FILENAME>" 
} */
+#define FOO 1
+#embed __FILE__ limit(0 + defined(FOO)) /* { dg-error "'defined' in #embed 
parameter" } */
+#embed /* { dg-error "#embed expects \\\"FILENAME\\\" or <FILENAME>" } */
+#embed "
+/* { dg-warning "missing terminating \\\" character" "" { target *-*-* } .-1 } 
*/
+ /* { dg-error "#embed expects \\\"FILENAME\\\" or <FILENAME>" "" { target 
*-*-* } .-2 } */
+#embed <
+/* { dg-error "empty filename in #embed" "" { target *-*-* } .-1 } */
+/* { dg-error "missing terminating > character" "" { target *-*-* } .-2 } */
+#embed >  /* { dg-error "#embed expects \\\"FILENAME\\\" or <FILENAME>" } */
+#embed "" /* { dg-error "empty filename in #embed" } */
+#embed <> /* { dg-error "empty filename in #embed" } */
+#embed embed-4.c  /* { dg-error "#embed expects \\\"FILENAME\\\" or 
<FILENAME>" } */
+#embed __FILE__ foo: /* { dg-error "expected parameter name" } */
+/* { dg-error "unknown embed parameter 'foo'" "" { target *-*-* } .-1 } */
+#embed __FILE__ bar:: /* { dg-error "expected parameter name" } */
+#embed __FILE__ :: /* { dg-error "expected parameter name" } */
+#embed __FILE__ foo:bar /* { dg-error "expected parameter name" } */
+/* { dg-error "unknown embed parameter 'foo'" "" { target *-*-* } .-1 } */
+#embed __FILE__ foo::bar::baz /* { dg-error "expected parameter name" } */
+/* { dg-error "unknown embed parameter 'foo::bar'" "" { target *-*-* } .-1 } */
+#embed __FILE__ foo : : bar /* { dg-error "expected parameter name" } */
+/* { dg-error "unknown embed parameter 'foo'" "" { target *-*-* } .-1 } */
+#embed __FILE__ 42 /* { dg-error "expected parameter name" } */
+#embed __FILE__ 42::foo /* { dg-error "expected parameter name" } */
+#embed __FILE__ foo::42 /* { dg-error "expected parameter name" } */
+#embed __FILE__ limit(1/0) /* { dg-error "division by zero in #embed" } */
--- gcc/testsuite/c-c++-common/cpp/embed-4.c.jj 2024-06-18 08:37:55.959485994 
+0200
+++ gcc/testsuite/c-c++-common/cpp/embed-4.c    2024-06-18 08:37:55.959485994 
+0200
@@ -0,0 +1,141 @@
+/* { dg-do preprocess } */
+/* { dg-options "" } */
+
+#if 1 + __has_embed (__FILE__ , limit(1)) /* { dg-error "expected parameter 
name" } */
+/* { dg-error "missing binary operator before token \\\"limit\\\"" "" { target 
*-*-* } .-1 } */
+#endif
+#if 1 + __has_embed (__FILE__ limit(1) /* { dg-error "expected '\\\)'" } */
+#endif
+#if 1 + __has_embed (__FILE__ limit(1) limit(1)) /* { dg-error "duplicate 
embed parameter 'limit'" } */
+#endif
+#if 1 + __has_embed (__FILE__ limit(1) prefix() prefix()) /* { dg-error 
"duplicate embed parameter 'prefix'" } */
+#endif
+#if 1 + __has_embed (__FILE__ limit(1) suffix(1 2 3) __suffix__()) /* { 
dg-error "duplicate embed parameter 'suffix'" } */
+#endif
+#if 1 + __has_embed (__FILE__ if_empty ("this") if_empty("that") limit(1)) /* 
{ dg-error "duplicate embed parameter 'if_empty'" } */
+#endif
+#if 1 + __has_embed (__FILE__ limit prefix() suffix()) /* { dg-error "expected 
'\\\('" } */
+#endif
+#if 1 + __has_embed (__FILE__ __prefix__ suffix() limit(1)) /* { dg-error 
"expected '\\\('" } */
+#endif
+#if 1 + __has_embed (__FILE__ prefix() suffix limit(1)) /* { dg-error 
"expected '\\\('" } */
+#endif
+#if 1 + __has_embed (__FILE__ if_empty limit(1)) /* { dg-error "expected 
'\\\('" } */
+#endif
+#if 1 + __has_embed (__FILE__ limit (1 / 0)) /* { dg-error "division by zero 
in #embed" } */
+#endif
+#if 1 + __has_embed (__FILE__ limit (+ + +)) /* { dg-error "operator '\\\+' 
has no right operand" } */
+#endif
+#if 1 + __has_embed (__FILE__ limit(1) prefix(()) /* { dg-error "expected 
'\\\)'" } */
+#endif
+#if 1 + __has_embed (__FILE__ limit(1) prefix(({[})])) /* { dg-error 
"unbalanced '\\\('" } */
+/* { dg-error "unbalanced '\\\)'" "" { target *-*-* } .-1 } */
+/* { dg-error "unbalanced '\\\{'" "" { target *-*-* } .-2 } */
+/* { dg-error "unbalanced '\\\}'" "" { target *-*-* } .-3 } */
+/* { dg-error "expected '\\\)'" "" { target *-*-* } .-4 } */
+#endif
+#if 1 + __has_embed (__FILE__ limit(1) prefix(])) /* { dg-error "unbalanced 
'\\\]'" } */
+#endif
+#if 1 + __has_embed (__FILE__ limit(1) prefix([)) /* { dg-error "unbalanced 
'\\\)'" } */
+/* { dg-error "unbalanced '\\\['" "" { target *-*-* } .-1 } */
+/* { dg-error "unbalanced '\\\('" "" { target *-*-* } .-2 } */
+/* { dg-error "expected '\\\)'" "" { target *-*-* } .-3 } */
+#endif
+#if 1 + __has_embed (__FILE__ limit(1) __suffix__(()) /* { dg-error "expected 
'\\\)'" } */
+#endif
+#if 1 + __has_embed (__FILE__ limit(1) __suffix__(({[})])) /* { dg-error 
"unbalanced '\\\('" } */
+/* { dg-error "unbalanced '\\\)'" "" { target *-*-* } .-1 } */
+/* { dg-error "unbalanced '\\\{'" "" { target *-*-* } .-2 } */
+/* { dg-error "unbalanced '\\\}'" "" { target *-*-* } .-3 } */
+/* { dg-error "expected '\\\)'" "" { target *-*-* } .-4 } */
+#endif
+#if 1 + __has_embed (__FILE__ limit(1) suffix([)) /* { dg-error "unbalanced 
'\\\)'" } */
+/* { dg-error "unbalanced '\\\['" "" { target *-*-* } .-1 } */
+/* { dg-error "unbalanced '\\\('" "" { target *-*-* } .-2 } */
+/* { dg-error "expected '\\\)'" "" { target *-*-* } .-3 } */
+#endif
+#if 1 + __has_embed (__FILE__ limit(1) if_empty(()) /* { dg-error "expected 
'\\\)'" } */
+#endif
+#if 1 + __has_embed (__FILE__ limit(1) __if_empty__(({[})])) /* { dg-error 
"unbalanced '\\\('" } */
+/* { dg-error "unbalanced '\\\)'" "" { target *-*-* } .-1 } */
+/* { dg-error "unbalanced '\\\{'" "" { target *-*-* } .-2 } */
+/* { dg-error "unbalanced '\\\}'" "" { target *-*-* } .-3 } */
+/* { dg-error "expected '\\\)'" "" { target *-*-* } .-4 } */
+#endif
+#if 1 + __has_embed (__FILE__ limit(1) __if_empty__([)) /* { dg-error 
"unbalanced '\\\)'" } */
+/* { dg-error "unbalanced '\\\['" "" { target *-*-* } .-1 } */
+/* { dg-error "unbalanced '\\\('" "" { target *-*-* } .-2 } */
+/* { dg-error "expected '\\\)'" "" { target *-*-* } .-3 } */
+#endif
+#if 1 + __has_embed (__FILE__ limit(1) gnu::non_existent_parameter(()) /* { 
dg-error "expected '\\\)'" } */
+#endif
+#if 1 + __has_embed (__FILE__ limit(1) 
__gnu__::__non_existent_parameter__(({[})])) /* { dg-error "unbalanced '\\\('" 
} */
+/* { dg-error "unbalanced '\\\)'" "" { target *-*-* } .-1 } */
+/* { dg-error "unbalanced '\\\{'" "" { target *-*-* } .-2 } */
+/* { dg-error "unbalanced '\\\}'" "" { target *-*-* } .-3 } */
+/* { dg-error "expected '\\\)'" "" { target *-*-* } .-4 } */
+#endif
+#if 1 + __has_embed (__FILE__ limit(1) __gnu__::__non_existent_parameter__([)) 
/* { dg-error "unbalanced '\\\)'" } */
+/* { dg-error "unbalanced '\\\['" "" { target *-*-* } .-1 } */
+/* { dg-error "unbalanced '\\\('" "" { target *-*-* } .-2 } */
+/* { dg-error "expected '\\\)'" "" { target *-*-* } .-3 } */
+#endif
+#define FOO 1
+#if 1 + __has_embed (limit(1)) /* { dg-error "operator \\\"__has_embed\\\" 
requires a header-name" } */
+/* { dg-error "missing binary operator before token \\\"1\\\"" "" { target 
*-*-* } .-1 } */
+#endif
+#if 1 + __has_embed (__FILE__ limit(0 + defined(FOO))) /* { dg-error 
"'defined' in #embed parameter" } */
+#endif
+int a = __has_embed (__FILE__); /* { dg-error "\\\"__has_embed\\\" used 
outside of preprocessing directive" } */
+#if __has_embed /* { dg-error "missing '\\\(' before \\\"__has_embed\\\" 
operand" } */
+/* { dg-error "operator \\\"__has_embed\\\" requires a header-name" "" { 
target *-*-* } .-1 } */
+#endif
+#if __has_embed( /* { dg-error "operator \\\"__has_embed\\\" requires a 
header-name" } */
+#endif
+#if __has_embed() /* { dg-error "operator \\\"__has_embed\\\" requires a 
header-name" } */
+#endif
+#if __has_embed(")
+/* { dg-warning "missing terminating \\\" character" "" { target *-*-* } .-1 } 
*/
+/* { dg-error "operator \\\"__has_embed\\\" requires a header-name" "" { 
target *-*-* } .-2 } */
+#endif
+#if __has_embed(<)
+/* { dg-error "missing terminating > character" "" { target *-*-* } .-1 } */
+/* { dg-error "expected '\\\)'" "" { target *-*-* } .-2 } */
+#endif
+#if __has_embed(>) /* { dg-error "operator \\\"__has_embed\\\" requires a 
header-name" } */
+#endif
+#if __has_embed("") /* { dg-error "empty filename in '__has_embed'" } */
+#endif
+#if __has_embed(<>) /* { dg-error "empty filename in '__has_embed'" } */
+#endif
+#if __has_embed(embed-4.c) /* { dg-error "operator \\\"__has_embed\\\" 
requires a header-name" } */
+/* { dg-error "missing binary operator before token \\\"4.c\\\"" "" { target 
*-*-* } .-1 } */
+#endif
+#if __has_embed(__FILE__ foo:) /* { dg-error "expected parameter name" } */
+/* { dg-error "missing '\\\(' in expression" "" { target *-*-* } .-1 } */
+#endif
+#if __has_embed(__FILE__ bar::) /* { dg-error "expected parameter name" } */
+#endif
+#if __has_embed(__FILE__ ::) /* { dg-error "expected parameter name" } */
+/* { dg-error "missing '\\\(' in expression" "" { target *-*-* } .-1 } */
+#endif
+#if __has_embed(__FILE__ foo:bar) /* { dg-error "expected parameter name" } */
+/* { dg-error "missing binary operator before token \\\"bar\\\"" "" { target 
*-*-* } .-1 } */
+#endif
+#if __has_embed(__FILE__ foo::bar::baz) /* { dg-error "expected parameter 
name" } */
+/* { dg-error "missing binary operator before token \\\"baz\\\"" "" { target 
*-*-* } .-1 } */
+#endif
+#if __has_embed(__FILE__ foo : : bar) /* { dg-error "expected parameter name" 
} */
+/* { dg-error "':' without preceding '\\\?'" "" { target *-*-* } .-1 } */
+#endif
+#if __has_embed(__FILE__ 42) /* { dg-error "expected parameter name" } */
+/* { dg-error "missing '\\\(' in expression" "" { target *-*-* } .-1 } */
+#endif
+#if __has_embed(__FILE__ 42::foo) /* { dg-error "expected parameter name" } */
+/* { dg-error "token \\\"::\\\" is not valid in preprocessor expressions" "" { 
target *-*-* } .-1 } */
+#endif
+#if __has_embed(__FILE__ foo::42) /* { dg-error "expected parameter name" } */
+/* { dg-error "missing '\\\(' in expression" "" { target *-*-* } .-1 } */
+#endif
+#if __has_embed(__FILE__ limit(1/0)) /* { dg-error "division by zero in 
#embed" } */
+#endif
--- gcc/testsuite/c-c++-common/cpp/embed-5.c.jj 2024-06-18 08:37:55.959485994 
+0200
+++ gcc/testsuite/c-c++-common/cpp/embed-5.c    2024-06-18 08:37:55.959485994 
+0200
@@ -0,0 +1,9 @@
+/* { dg-do preprocess } */
+/* { dg-options "" } */
+
+#undef FOOBAR
+#embed __FILE__ prefix (#include <non-existent-file.h>) suffix (#define FOOBAR 
baz) if_empty (#error "abcd")
+#embed __FILE__ __prefix__(#define FOOBAR baz)
+#ifdef FOOBAR
+#error "FOOBAR is defined"
+#endif
--- gcc/testsuite/c-c++-common/cpp/embed-6.c.jj 2024-06-18 08:37:55.959485994 
+0200
+++ gcc/testsuite/c-c++-common/cpp/embed-6.c    2024-06-18 08:37:55.959485994 
+0200
@@ -0,0 +1,24 @@
+/* { dg-do preprocess } */
+/* { dg-options "-M -nostdinc 
--embed-dir=${srcdir}/c-c++-common/cpp/embed-dir" } */
+
+#if __has_embed ("embed-1.c")
+#embed "magna-carta.txt" limit(1)
+#embed "magna-carta.txt" limit(64)
+#embed "magna-carta.txt" prefix(1 +)suffix(+ 42)if_empty()
+#elif
+#embed "non-existent-file"
+#endif
+#if 1 || __has_embed ("embed-2.c")
+#embed <embed-1.inc>
+#embed <embed-4.c>
+#embed "embed-3.c"
+#endif
+
+/* { dg-final { scan-file embed-6.i "(^|\\n)embed-6.o:" } }
+   { dg-final { scan-file embed-6.i "embed-6.c" } }
+   { dg-final { scan-file embed-6.i 
"c-c..-common/cpp/embed-dir/magna-carta.txt" } }
+   { dg-final { scan-file embed-6.i "c-c..-common/cpp/embed-dir/embed-1.inc" } 
}
+   { dg-final { scan-file embed-6.i "c-c..-common/cpp/embed-dir/embed-4.c" } }
+   { dg-final { scan-file embed-6.i "(\[^/]|cpp/)embed-3.c" } } */
+/* { dg-final { scan-file-not embed-6.i "embed-1.c" } }
+   { dg-final { scan-file-not embed-6.i "embed-2.c" } } */
--- gcc/testsuite/c-c++-common/cpp/embed-7.c.jj 2024-06-18 08:37:55.959485994 
+0200
+++ gcc/testsuite/c-c++-common/cpp/embed-7.c    2024-06-18 08:37:55.959485994 
+0200
@@ -0,0 +1,5 @@
+/* { dg-do preprocess } */
+/* { dg-options "" } */
+
+#embed "non-existent-file" /* { dg-error "non-existent-file: No such file or 
directory" } */
+/* { dg-prune-output "compilation terminated" } */
--- gcc/testsuite/c-c++-common/cpp/embed-8.c.jj 2024-06-18 08:37:55.960485981 
+0200
+++ gcc/testsuite/c-c++-common/cpp/embed-8.c    2024-06-18 08:37:55.960485981 
+0200
@@ -0,0 +1,5 @@
+/* { dg-do preprocess } */
+/* { dg-options "--embed-dir=${srcdir}/c-c++-common/cpp/embed-dir" } */
+
+#embed <non-existent-file> /* { dg-error "non-existent-file: No such file or 
directory" } */
+/* { dg-prune-output "compilation terminated" } */
--- gcc/testsuite/c-c++-common/cpp/embed-9.c.jj 2024-06-18 08:37:55.960485981 
+0200
+++ gcc/testsuite/c-c++-common/cpp/embed-9.c    2024-06-18 08:37:55.960485981 
+0200
@@ -0,0 +1,4 @@
+/* { dg-do preprocess } */
+/* { dg-options "" } */
+
+#embed <non-existent-file> /* { dg-error "no include path in which to search 
for non-existent-file" } */
--- gcc/testsuite/c-c++-common/cpp/embed-10.c.jj        2024-06-18 
08:37:55.960485981 +0200
+++ gcc/testsuite/c-c++-common/cpp/embed-10.c   2024-06-18 08:37:55.960485981 
+0200
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "--embed-dir=${srcdir}/c-c++-common/cpp/embed-dir" } */
+
+const char *p =
+#embed <magna-carta.txt> limit (42)
+;
+/* { dg-error "makes pointer from integer without a cast" "" { target c } .-2 
} */
+/* { dg-error "expected identifier" "" { target c } .-3 } */
+/* { dg-error "invalid conversion" "" { target c++ } .-4 } */
+/* { dg-error "expected unqualified-id before numeric constant" "" { target 
c++ } .-5 } */
--- gcc/testsuite/c-c++-common/cpp/embed-11.c.jj        2024-06-18 
08:37:55.960485981 +0200
+++ gcc/testsuite/c-c++-common/cpp/embed-11.c   2024-06-18 08:37:55.960485981 
+0200
@@ -0,0 +1,27 @@
+/* { dg-do run { target native } } */
+/* { dg-options 
"-DMAGNA_CARTA=\"${srcdir}/c-c++-common/cpp/embed-dir/magna-carta.txt\"" } */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+int
+main (void)
+{
+  static const unsigned char embed_data[] = {
+    #embed MAGNA_CARTA
+  };
+  char f_data[sizeof (embed_data)];
+  FILE *f_source = fopen (MAGNA_CARTA, "rb");
+  if (f_source == NULL)
+    abort ();
+  if (fread (f_data, 1, sizeof (embed_data),
+            f_source) != sizeof (embed_data))
+    {
+      fclose (f_source);
+      abort ();
+    }
+  fclose (f_source);
+  if (memcmp (&embed_data[0], f_data, sizeof (embed_data)))
+    abort ();
+}
--- gcc/testsuite/c-c++-common/cpp/embed-12.c.jj        2024-06-18 
08:37:55.961485968 +0200
+++ gcc/testsuite/c-c++-common/cpp/embed-12.c   2024-06-18 08:37:55.961485968 
+0200
@@ -0,0 +1,18 @@
+/* { dg-do preprocess } */
+/* { dg-options "" } */
+
+#if __has_embed (__FILE__ limit (-1)) /* { dg-error "negative embed parameter 
operand" } */
+#endif
+#if __has_embed (__FILE__ limit (-42)) /* { dg-error "negative embed parameter 
operand" } */
+#endif
+#if __has_embed (__FILE__ limit (-9223372036854775807 - 1)) /* { dg-error 
"negative embed parameter operand" } */
+#endif
+#if __has_embed (__FILE__ limit (18446744073709551615ULL))
+#endif
+#if __has_embed (__FILE__ limit (18446744073709551615ULL + 42))
+#endif
+#embed __FILE__ limit (-1) /* { dg-error "negative embed parameter operand" } 
*/
+#embed __FILE__ limit (-42) /* { dg-error "negative embed parameter operand" } 
*/
+#embed __FILE__ limit (-9223372036854775807 - 1) /* { dg-error "negative embed 
parameter operand" } */
+#embed __FILE__ limit (18446744073709551615ULL)
+#embed __FILE__ limit (18446744073709551615ULL + 42)
--- gcc/testsuite/c-c++-common/cpp/embed-13.c.jj        2024-06-18 
18:14:11.251642443 +0200
+++ gcc/testsuite/c-c++-common/cpp/embed-13.c   2024-06-18 15:22:12.681920923 
+0200
@@ -0,0 +1,12 @@
+/* { dg-do preprocess } */
+/* { dg-options "-P" } */
+
+#if __has_embed(__FILE__ limit(6))
+#define FOO 20000,20001,20002
+#define BAR 30000,30001,30002
+#embed __FILE__ limit (4) prefix(10000,10001,10002+) suffix(+10003,10004,10005)
+#embed __FILE__ limit (6) prefix(FOO,) suffix(,BAR)
+#endif
+
+/* { dg-final { scan-file embed-13.i "10000,10001,10002\\\+\[ 
\t\n\r]*\[0-9]+,\[0-9]+,\[0-9]+,\[0-9]+\[ \t\n\r]*\\\+10003,10004,10005" } } */
+/* { dg-final { scan-file embed-13.i "20000,20001,20002,\[ 
\t\n\r]*\[0-9]+,\[0-9]+,\[0-9]+,\[0-9]+,\[0-9]+,\[0-9]+\[ 
\t\n\r]*,30000,30001,30002" } } */
--- gcc/testsuite/c-c++-common/cpp/embed-14.c.jj        2024-06-18 
15:20:03.178584313 +0200
+++ gcc/testsuite/c-c++-common/cpp/embed-14.c   2024-06-18 15:25:31.564366384 
+0200
@@ -0,0 +1,13 @@
+/* { dg-do preprocess } */
+/* { dg-options "-P -fdirectives-only" } */
+
+#if __has_embed(__FILE__ limit(6))
+#define FOO 20000,20001,20002
+#define BAR 30000,30001,30002
+#embed __FILE__ limit (4) prefix(10000,10001,10002+) suffix(+10003,10004,10005)
+#embed __FILE__ limit (6) prefix(FOO,) suffix(,BAR)
+#endif
+
+/* { dg-final { scan-file embed-14.i "10000,10001,10002\\\+\[ 
\t\n\r]*\[0-9]+,\[0-9]+,\[0-9]+,\[0-9]+\[ \t\n\r]*\\\+10003,10004,10005" } } */
+/* { dg-final { scan-file embed-14.i "20000,20001,20002,\[ 
\t\n\r]*\[0-9]+,\[0-9]+,\[0-9]+,\[0-9]+,\[0-9]+,\[0-9]+\[ 
\t\n\r]*,30000,30001,30002" } } */
+/* { dg-final { scan-file-not embed-14.i "\[#]embed" } } */
--- gcc/testsuite/c-c++-common/cpp/embed-dir/embed-1.inc.jj     2024-06-18 
08:37:55.961485968 +0200
+++ gcc/testsuite/c-c++-common/cpp/embed-dir/embed-1.inc        2024-06-18 
08:37:55.961485968 +0200
@@ -0,0 +1 @@
+a
\ No newline at end of file
--- gcc/testsuite/c-c++-common/cpp/embed-dir/embed-3.c.jj       2024-06-18 
08:37:55.961485968 +0200
+++ gcc/testsuite/c-c++-common/cpp/embed-dir/embed-3.c  2024-06-18 
08:37:55.961485968 +0200
@@ -0,0 +1,4 @@
+/* { dg-do preprocess } */
+
+/* Dummy file.  */
+int i;
--- gcc/testsuite/c-c++-common/cpp/embed-dir/embed-4.c.jj       2024-06-18 
08:37:55.961485968 +0200
+++ gcc/testsuite/c-c++-common/cpp/embed-dir/embed-4.c  2024-06-18 
08:37:55.961485968 +0200
@@ -0,0 +1,3 @@
+/* { dg-do preprocess } */
+
+int i;
--- gcc/testsuite/c-c++-common/cpp/embed-dir/magna-carta.txt.jj 2024-06-18 
08:37:55.962485955 +0200
+++ gcc/testsuite/c-c++-common/cpp/embed-dir/magna-carta.txt    2024-06-18 
08:37:55.962485955 +0200
@@ -0,0 +1,46 @@
+Henrícus Dei grátia rex Angliæ, dóminus Hibérniæ, dux Normánniæ, Aquitániæ, et 
comes Andegáviæ, archiepíscopis, epíscopis, abbátibus, prióribus, comítibus, 
barónibus, vicecomítibus, præpósitis, minístris et ómnibus ballívis et 
fidélibus suis præséntem cartam inspectúris, salútem. Sciátis quod nos, intúitu 
Dei et pro salúte ánime nostre et animárum antecessórum et successórum 
nostrórum, ad exaltatiónem sancte ecclésiæ et emendatiónem regni nostri, 
spontánea et bona voluntáte nostra, dédimus et concéssimus archiepíscopis, 
epíscopis, abbátibus, prióribus, comítibus, barónibus et ómnibus de regno 
nostro has libertátes subscríptas tenéndas in regno nostro Angliæ in perpétuum.
+In primis concéssimus Deo et hac præsénti carta nostra confirmávimus pro nobis 
et herédibus nostris in perpétuum quod anglicána ecclésia líbera sit, et hábeat 
ómnia iura sua íntegra et libertátes suas illǽsas. Concéssimus étiam ómnibus 
líberis homínibus regni nostri pro nobis et herédibus nostris in perpétuum 
omnes libertátes subscríptas, habéndas et tenéndas eis et herédibus suis de 
nobis et herédibus nostris in perpétuum.
+Si quis cómitum vel barónum nostrórum sive aliórum tenéncium de nobis in 
cápite per servícium militáre mórtuus fúerit, et, cum decésserit, heres eius 
plene ætátis fúerit et relévium débeat, hábeat hereditátem suam per antíquum 
relévium, scílicet heres vel herédes cómitis de barónia cómitis íntegra per 
centum libras, heres vel herédes barónis de barónia íntegra per centum libras, 
heres vel herédes mílitis de feódo mílitis íntegro per centum sólidos ad plus; 
et qui minus debúerit minus det secúndum antíquam consuetúdinem feodórum.
+Si autem heres alícuius tálium fúerit infra etatem, dóminus eius non hábeat 
custódiam eius nec terre sue ántequam homágium eius céperit; et, postquam talis 
heres fúerit in custódia, cum ad etatem pervénerit, scílicet vigínti et únius 
anni, hábeat hereditátem suam sine relévio et sine fine, ita tamen quod, si 
ipse, dum infra etatem fúerit, fiat miles, nichilominus terra remáneat in 
custódia dominórum suórum usque ad términum prædíctum.
+Custos terre huiúsmodi herédis qui infra etatem fúerit non cápiat de terra 
herédis nisi rationábiles éxitus et rationábiles consuetúdines et rationabília 
servícia, et hoc sine destructióne et vasto hóminum vel rerum; et si nos 
commisérimus custódiam alícuius talis terre vicecomíti vel alícui álii qui de 
exítibus terre illíus nobis débeat respondére, et ille destructiónem de 
custódia fécerit vel vastum, nos ab illo capiémus eméndam, et terra committétur 
duóbus legálibus et discrétis homínibus de feódo illo qui de exítibus nobis 
respóndeant vel ei cui eos assignavérimus; et si dedérimus vel vendidérimus 
alícui custódiam alícuius talis terre, et ille destructiónem inde fécerit vel 
vastum, amíttat ipsam custódiam et tradátur duóbus legálibus et discrétis 
homínibus de feódo illo qui simíliter nobis respóndeant, sicut prædíctum est.
+Custos autem, quámdiu custódiam terre habúerit, susténtet domos, parcos, 
vivária, stagna, molendína et cétera ad terram illam pertinéncia de exítibus 
terre eiusdem, et reddat herédi, cum ad plenam etatem pervénerit, terram suam 
totam instaurátam de carúcis et ómnibus áliis rebus, ad minus secúndum quod 
illam recépit. Hec ómnia observéntur de custódiis archiepiscopátuum, 
episcopátuum, abbatiárum, priorátuum, ecclesiárum et dignitátum vacáncium que 
ad nos pértinent, excépto quod huiúsmodi custódie vendi non debent.
+Herédes mariténtur absque disparagatióne.
+Vídua post mortem maríti sui statim et sine difficultáte áliqua hábeat 
maritágium suum et hereditátem suam, nec áliquid det pro dote sua vel pro 
maritagio suo vel pro hereditáte sua, quam hereditátum marítus suus et ipsa 
tenuérunt die óbitus ípsius maríti, et máneat in capitáli meságio maríti sui 
per quadrangínta dies post óbitum ípsius maríti sui, infra quos assignétur ei 
dos sua, nisi prius et fúerit assignáta, vel nisi domus illa sit castrum; et si 
de castro recésserit, statim provideátur ei domus cómpetens in qua possit 
honéste morári, quoúsque doe sua ei assignétur secúndum quod prædíctum est, et 
hábeat rationábile estovérium suum ínterim de commúni. Assignétur autem ei pro 
dote sua tércia pars tócius terre maríti sui que sua fuit in vita sua, nisi de 
minóri dotáta fúerit ad hóstium ecclésiæ.
+Nulla vídua distringátur ad se maritándam, dum vívere volúerit sine maríto, 
ita tamen quod securitátem fáciet quod se non maritábit sine assénsu nostro, si 
de nobis tenúerit, vel sine assénsu dómini sui, si de áliquo tenúerit.
+Nos vero vel bállivi nostri non seisiémus terram áliquam nec rédditum pro 
débito áliquo quámdiu catálla debitóris præséncia suffíciant ad débitum 
reddéndum et ipse débitor parátus sit inde satisfácere; nec plégii ípsius 
debitóris distringántur quámdiu ipse capitális débitor suffíciat ad solutiónem 
débiti; et, si capitális débitor defécerit in solutióne débiti, non habens unde 
reddat aut réddere rolit cum possit, plégii respóndeant pro débito; et, si 
volúerint, hábeant terras et rédditus debitóris quoúsque sit eis satisfáctum de 
débito quod ante pro eo solvérunt, nisi capitális débitor monstráverit se inde 
esse quiétum versus eósdem plégios.
+Cívitas Londóniæ hábeat omnes antíquas libertátes et líberas consuetúdines 
suas. Pretérea vólumus et concédimus quod omnes álie civitátes, et burgi, et 
ville, et barónes de quinque pórtubus, et omnes portus, hábeant omnes 
libertátes et líberas consuetúdines suas.
+Nullus distringátur ad faciéndum maius servícium de feódo mílitis nec de álio 
líbero teneménto quam inde debétur.
+Commúnia plácita non sequántur cúriam nostram, set teneántur in áliquo loco 
certo.
+Recognitiónes de nova disseísina et de morte antecessóris non capiántur nisi 
in suis comitátibus, et hoc modo: nos, vel si extra regnum fuérimus, capitális 
iusticiárius noster, mittémus iusticiários per unumquémque comitátum semel in 
anno, qui cum milítibus comitátuum cápiant in comitátibus assísas prædíctas. Et 
ea que in illo advéntu suo in comitátu per iusticiários prædíctos ad dictas 
assísas capiéndas missos terminári non possunt, per eósdem terminéntur álibi in 
itínere suo; et ea que per eósem propter difficultátem aliquórum articulórum 
terminári non possunt, refer-antur ad iusticiários, nostros de banco, et ibi 
terminéntur.
+Assise de última præsentatióne semper capiántur coram iusticiáriis nostris de 
banco et ibi terminéntur.
+Liber homo non amerciétur pro parvo delícto nisi secúndum modum ípsius 
delícti, et pro magno delícto, secúndum magnitúdinem delícti, salvo 
conteneménto suo; et mercátor eódem modo salva mercandísa sua; et villánus 
altérius quam noster eódem modo amerciétur salvo wainágio suo, si incíderit in 
misericórdiam nostram; et nulla prædictárum misericordiárum ponátur nisi per 
sacraméntum probórum et legálium hóminum de visnéto.
+Cómites et barónes non amerciéntur nisi per pares suos, et non nisi secúndum 
modum delícti.
+Nulla ecclesiástica persóna amerciétur secúndum quantitátem benefícii sui 
ecclesiástici, set secúndum láicum teneméntum suum, et secúndum quantitátem 
delícti.
+Nec villa, nec homo, distringátur fácere pontes ad ripárias nisi que ex 
antíquo et de iure fácere debet.
+Nulla ripária decétero defendátur, nisi ille que fuérunt in defénso témpore 
regis Henríci avi nostri, per eádem loca et eósdem términos sicut esse 
consuevérunt témpore suo.
+Nullus vicecómes, constabulárius, coronatóres vel álii bállivi nostri téneant 
plácita corone nostre.
+Si áliquis tenens de nobis láicum feódum moriátur, et vice-comes vel ballívus 
noster osténdat lítteras nostras paténtes de summonitióne nostra de débito quod 
defúnctus nobis débuit, líceat vicecomíti vel ballivo nostro attachiáre et 
inbreviáre cátalla defúncti invénta in láico feódo ad valénciam illíus débiti 
per visum legálium hóminum, ita tamen quod nichil inde amoveátur donec 
persolvátur nobis débitum quod clarum fúerit, et resíduum relinquátur 
executóribus ad faciéndum testaméntum defúncti; et si nichil nobis debeátur ab 
ipso, ómnia cátalla cedant defúncto, salvis uxóri ípsius et púeris suis 
rationabílibus pártibus suis.
+Nullus constabulárius vel eius ballívus cápiat blada vel ália cátalla alícuius 
qui non sit de villa ubi castrum situm est, nisi statim inde reddat denários 
aut respéctum inde habére possit de voluntáte venditóris; si autem de villa 
ipsa fúerit, infra quadragínta dies précium reddat.
+Nullus constabulárius distríngat áliquem mílitem ad dandum denários pro 
custódia castri, si ipse eam fácere volúerit in própria persóna sua, vel per 
álium probum hóminem, si ipse eam fácere non possit propter rationábilem 
causam, et, si nos duxérimus eum vel misérimus in exércitum, erit quiétus de 
custódia secúndum quantitátem témporis quo per nos fúerit in exércitu de feódo 
pro quo fecit servícium in exércitu.
+Nullus vicecómes, vel ballívus noster, vel álius cápiat equos vel caréttas 
alícuius pro cariagio faciéndo, nisi reddat liberatiónem antíquitus statútam, 
scílicet pro carétta ad duos equos decem denários per diem, et pro carétta ad 
tres equos quatuórdecim denários per diem. Nulla carétta domínica alícuius 
ecclesiástice pérsone vel mílitis vel alícuius dómine capiátur per ballivos 
prædíctos.
+Nec nos nec bállivi nostri nec álii capiémus aliénum boscum ad castra vel ália 
agénda nostra, nisi per voluntátem illíus cuius boscus ille fúerit.
+Nos non tenébimus terras eórum qui convícti fúerint de felónia, nisi per unum 
annum et unum diem; et tunc reddántur terre dóminis feodórum.
+Omnes kidélli decétero deponántur penítus per Tamísiam et Medéweiam et per 
totam Angliam, nisi per costéram maris.
+Breve quod vocátur Précipe decétero non fiat alícui de áliquo tenaménto, unde 
liber homo perdat cúriam suam.
+Una mensúra vini sit per totum regnum nostrum, et una mensúra cervísiæ, et una 
mensúra bladi, scílicet quartérium London, et una latitúdo pannórum tinctórum 
et russettórum et haubergettórum, scílicet due ulne infra listas; de pondéribus 
vero sit ut de mensúris.
+Nihil detur de cétero pro brevi inquisitiónis ab eo qui inquisitiónem petit de 
vita vel membris, set gratis concedátur et non negétur.
+Si áliquis téneat de nobis per feodifírmam vel soccágium, vel per burgágium, 
et de álio terram téneat per servícium militáre, nos non habébimus custódiam 
herédis nec terre sue que est de feódo altérius, occasióne illíus feodifírme, 
vel soccágii, vel burgágii, nec habébimus custódiam illíus feodifírme vel 
soccágii vel burgágii, nisi ipsa feodifírma débeat servícium militáre. Nos non 
habébimus custódiam herédis nec terre alícuius quam tenet de álio per servícium 
militáre, occasióne alícuius parve seriantériæ quam tenet de nobis per 
servícium reddéndi nobis cultéllos, vel sagíttas, vel huiúsmodi.
+Nullus ballívus ponat decétero áliquem ad legem maniféstam vel ad iuraméntum 
símplici loquéla sua, sine téstibus fidélibus ad hoc indúctis.
+Nullus liber homo decétero capiátur vel imprisonétur aut disseisiátur de 
áliquo líbero teneménto suo vel libertátibus vel líberis consuetudínibus suis, 
aut utlagétur, aut exulétur aut áliquo álio modo destruátur, nec super eum 
íbimus, nec super eum mittémus, nisi per legále iudícium párium suórum, vel per 
legem terre.
+Nulli vendémus, nulli negábimus aut differémus rectum vel iustíciam.
+Omnes mercatóres, nisi públice ántea prohíbiti fúerint, hábeant salvum et 
secúrum exíre de Anglia, et veníre in Angliam, et morári, et ire per Angliam 
tam per terram quam per aquam ad eméndum vel vendéndum sine ómnibus toltis 
malis per antíquas et rectas consuetúdines, preterquam in témpore gwerre, et si 
sint de terra contra nos gwérrina; et si tales inveniántur in terra nostra in 
princípio gwerre, attachientur sine dampno córporum vel rerum, donec sciátur a 
nobis vel a capitáli iusticiário nostro quómodo mercatóres terre nostre 
tracténtur, qui tunc inveniéntur in terra contra nos gwérrina; et, si nostri 
salvi sint ibi, álii salvi sint in terra nostra.
+Si quis tenúerit de áliqua escǽta, sicut de honóre Wallingefórdiæ, Bolóniæ, 
Notingeham, Lancástriæ, vel de áliis que sunt in manu nostra, et sint barónie, 
et obíerit, heres eius non det aliud relévium nec fiat nobis aliud servícium 
quam fáceret baróni, si ipsa esset in manu barónis; et nos eódem modo eam 
tenébimus quo baro eam ténuit, nec nos, occasióne talis barónie vel escæte, 
habébimus áliquam escǽtam vel custódiam aliquórum hóminum nostrórum, nisi álibi 
tenúerit de nobis in cápite ille qui ténuit baróniam vel escǽtam.
+Nullus liber homo decétero det ámplius alícui vel vendat de terra sua quam ut 
de resíduo terre sue possit sufficiénter fíeri dómino feódi servícium ei 
débitum quod pértinet ad feódum illud.
+Omnes patróni abbatiárum qui habent cartas regum Angliæ de advocatióne, vel 
antíquam tenúram vel possessiónem, hábeant eárum custódiam cum vacáverint, 
sicut habére debent, et sicut supra declarátum est.
+Nullus capiátur vel imprisonétur propter appéllum fémine de morte altérius 
quam viri sui.
+Nullus comitátus decétero teneátur, nisi de mense in mensem; et, ubi maior 
términus esse solébat, maior sit. Nec áliquis vicecómes vel ballívus fáciat 
turnum suum per hundrédum nisi bis in anno et non nisi in loco débito et 
consuéto, vidélicet semel post Pascha et íterum post festum sancti Michaélis. 
Et visus de franco plegio tunc fiat ad illum términum sancti Michális sine 
occasióne, ita scílicet quod quilíbet hábeat libertátes suas quas hábuit et 
habére consuévit témpore regis Henríci avi nostri, vel quas póstea perquisívit. 
Fiat autem visus de franco plegio sic, vidélicet quod pax nostra teneátur, et 
quod tethinga íntegra sit sicut esse consuévit, et quod vicecómes non quérat 
occasiónes, et quod contintus sit eo quod vicecómes habére consuévit de visu 
suo faciéndo témpore regis Henríci avi nostri.
+Non líceat alícui decétero dare terram suam alícui dómui religióse, ita quod 
eam resúmat tenéndam de eádem domo, nec líceat alícui dómui religióse terram 
alícuius sic accípere quod tradat illam ei a quo ipsam recépit tenéndam. Si 
quis autem de cétero terram suam alícui dómui religióse sic déderit, et super 
hoc convincátur, donum suum penítus cassétur, et terra illa dómino suo illíus 
feódi incurrátur.
+Scutágium decétero capiátur sicut capi solébat témpore regis Henríci avi 
nostri. Et salve sint archiepíscopis, epíscopis, abbátibus, prióribus, 
templáriis, hospitaláriis, comítibus, barónibus et ómnibus áliis tam 
ecclesiásticis quam seculáribus persónis libertátes et líbere consuetúdines 
quas prius habuérunt.
+Omnes autem istas consuetúdines prædíctas et libertátes quas concéssimus in 
regno nostro tenéndas quantum ad nos pértinet erga nostros, omnes de regno 
nostro tam clérici quam láici obsérvent quantum ad se pértinet erga suos. Pro 
hac autem concessióne et donatióne libertátum istárum et aliárum libertátum 
contentárum in carta nostra de libertátibus fóreste, archiepíscopi, epíscopi, 
abbátes, prióres, cómites, barónes, mílites, líbere tenéntes, et omnes de regno 
nostro dedérunt nobis quintam décimam partem ómnium mobílium suórum. 
Concéssimus étiam eísdem pro nobis et herédibus nostris quod nec nos nec 
herédes nostri áliquid perquirémus per quod libertátes in hac carta conténte 
infringántur vel infirméntur; et, si de áliquo áliquid contra hoc perquisítum 
fúerit, nichil váleat et pro nullo habeátur.
+His téstibus dómino Stéphano Cantuariensi archiepíscopo, Eustáchio 
Lundoniensi, Iocelino Bathoniensi, Petro Wintoniensi, Hugoni Lincolniensi, 
Ricardo Sarrisberiensi, Benedícto Roffensi, Willelmo Wigorniensi, Iohanne 
Eliensi, Hugone Herefordiensi, Radulpho Cicestriensi, Willelmo Exoniensi 
epíscopis, abbáte sancti Albáni, abbáte sancti Edmundi, abbáte de Bello, abbáte 
sancti Augustíni Cantuariensis, abbáte de Evashamia, abbáte de Westmonasterio, 
abbáte de Burgo sancti Petri, abbáte Radingensi, abbáte Abbendoniensi, abbáte 
de Maumeburia, abbáte de Winchecomba, abbáte de Hida, abbáte de Certeseia, 
abbáte de Sire-burnia, abbáte de Cerne, abbáte de Abbotebiria, abbáte de 
Middletonia, abbáte de Seleby, abbáte de Wyteby, abbáte de Cirencestria, 
Huberto de Burgo iusticiário, Ranulfo cómite Cestrie et Lincolnie, Willelmo 
cómite Sarrisberie, Willelmo cómite Warennie, Gilberto de Clara cómite 
Gloucestrie et Hertfordie, Willelmo de Ferráriis cómite Derbeie, Willelmo de 
Mandevilla cómite Essexie, Hugone Le Bigod cómite Norfolcie, Willelmo cómite 
Aubemarle, Hunfrido cómite Herefordie, Iohanne constabulario Cestrie, Roberto 
de Ros, Roberto fílio Walteri, Roberto de Véteri ponte, Willielmo Brigwerre, 
Ricardo de Munfichet, Petro fílio Herberti, Matheo fílio Herberti, Willielmo de 
Albiniaco, Roberto Gresley, Reginaldo de Brahus, Iohanne de Munemutha, Iohanne 
fílio Aláni, Hugone de Mortuomari, Waltero de Bellocampo, Willielmo de sancto 
Iohanne, Petro de Malalacu, Briano de Insula, Thoma de Muletonia, Ricardo de 
Argentein., Gaulfrido de Nevilla, Willielmo Mauduit, Iohanne de Baalun.
+Datum apud Westmonastérium undécimo die februárii anno regni nostri nono.
--- gcc/testsuite/gcc.dg/cpp/embed-1.c.jj       2024-06-18 08:37:55.962485955 
+0200
+++ gcc/testsuite/gcc.dg/cpp/embed-1.c  2024-06-18 08:37:55.962485955 +0200
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+/* { dg-options "-std=c23 -pedantic-errors 
--embed-dir=${srcdir}/c-c++-common/cpp/embed-dir" } */
+
+#include "../../c-c++-common/cpp/embed-1.c"
--- gcc/testsuite/gcc.dg/cpp/embed-2.c.jj       2024-06-18 08:37:55.962485955 
+0200
+++ gcc/testsuite/gcc.dg/cpp/embed-2.c  2024-06-18 08:37:55.962485955 +0200
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-std=c17 -pedantic-errors -Wall -W" } */
+
+#if __has_embed (__FILE__ limit (1)) != 1
+#error "__has_embed failed"
+#endif
+
+int a =
+#embed __FILE__ limit (1) /* { dg-error "#embed before C23 is a GCC extension" 
} */
+;
+int b =
+(__extension__
+#embed __FILE__ limit (1)
+);
--- gcc/testsuite/gcc.dg/cpp/embed-3.c.jj       2024-06-18 08:37:55.963485942 
+0200
+++ gcc/testsuite/gcc.dg/cpp/embed-3.c  2024-06-18 08:37:55.963485942 +0200
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-std=c17 -pedantic -Wall -W" } */
+
+#if __has_embed (__FILE__ limit (1)) != 1
+#error "__has_embed failed"
+#endif
+
+int a =
+#embed __FILE__ limit (1) /* { dg-warning "#embed before C23 is a GCC 
extension" } */
+;
+int b =
+(__extension__
+#embed __FILE__ limit (1)
+);
--- gcc/testsuite/gcc.dg/cpp/embed-4.c.jj       2024-06-18 15:59:58.816785039 
+0200
+++ gcc/testsuite/gcc.dg/cpp/embed-4.c  2024-06-18 16:06:07.770040610 +0200
@@ -0,0 +1,13 @@
+/* { dg-do preprocess } */
+/* { dg-options "-traditional-cpp" } */
+
+#if __has_embed(__FILE__ limit(6))
+#endif
+/* { dg-error "-:'__has_embed' not supported in traditional C" "" { target 
*-*-* } .-2 } */
+/* { dg-error "-:missing binary operator before token \\\"\\\(\\\"" "" { 
target *-*-* } .-3 } */
+#define FOO 20000,20001,20002
+#define BAR 30000,30001,30002
+#embed __FILE__ limit (4) prefix(10000,10001,10002+) suffix(+10003,10004,10005)
+/* { dg-error "-:#embed not supported in traditional C" "" { target *-*-* } 
.-1 } */
+#embed __FILE__ limit (6) prefix(FOO,) suffix(,BAR)
+/* { dg-error "-:#embed not supported in traditional C" "" { target *-*-* } 
.-1 } */
--- gcc/testsuite/g++.dg/cpp/embed-1.C.jj       2024-06-18 08:37:55.963485942 
+0200
+++ gcc/testsuite/g++.dg/cpp/embed-1.C  2024-06-18 08:37:55.963485942 +0200
@@ -0,0 +1,14 @@
+// { dg-do compile }
+// { dg-options "-pedantic-errors -Wall -W" }
+
+#if __has_embed (__FILE__ limit (1)) != 1
+#error "__has_embed failed"
+#endif
+
+int a =
+#embed __FILE__ limit (1) // { dg-error "#embed is a GCC extension" }
+;
+int b =
+(__extension__
+#embed __FILE__ limit (1) // { dg-error "#embed is a GCC extension" }
+);
--- gcc/testsuite/g++.dg/cpp/embed-2.C.jj       2024-06-18 08:37:55.963485942 
+0200
+++ gcc/testsuite/g++.dg/cpp/embed-2.C  2024-06-18 08:37:55.963485942 +0200
@@ -0,0 +1,14 @@
+// { dg-do compile }
+// { dg-options "-pedantic -Wall -W" }
+
+#if __has_embed (__FILE__ limit (1)) != 1
+#error "__has_embed failed"
+#endif
+
+int a =
+#embed __FILE__ limit (1) // { dg-warning "#embed is a GCC extension" }
+;
+int b =
+(__extension__
+#embed __FILE__ limit (1) // { dg-warning "#embed is a GCC extension" }
+);
--- gcc/testsuite/g++.dg/cpp/embed-3.C.jj       2024-06-18 08:37:55.963485942 
+0200
+++ gcc/testsuite/g++.dg/cpp/embed-3.C  2024-06-18 08:37:55.963485942 +0200
@@ -0,0 +1,48 @@
+// { dg-do compile { target c++11 } }
+// { dg-options "--embed-dir=${srcdir}/c-c++-common/cpp/embed-dir" }
+
+template <int... N>
+constexpr decltype (sizeof 0)
+foo ()
+{
+  return sizeof... (N);
+}
+
+template <typename T, typename U>
+struct same_type;
+template <typename T>
+struct same_type <T, T> {};
+
+void
+bar ()
+{
+}
+
+template <typename U, typename... T>
+same_type <U, int> *
+bar (U u, T... t)
+{
+  bar (t...);
+  return nullptr;
+}
+
+static_assert (
+#embed <magna-carta.txt> limit (1) prefix (foo <) suffix (> () == 1, "")
+);
+static_assert (
+#embed <magna-carta.txt> limit (2) prefix (foo <) suffix (> () == 2, "")
+);
+static_assert (
+#embed <magna-carta.txt> limit (42) prefix (foo <) suffix (> () == 42, "")
+);
+static_assert (
+#embed <magna-carta.txt> limit (521) prefix (foo <) suffix (> () == 521, "")
+);
+
+void
+baz ()
+{
+  bar (
+#embed "magna-carta.txt" limit (54)
+      );
+}

        Jakub

Reply via email to