--- libcpp/include/cpplib.h.jj	2024-02-22 19:28:53.617865978 +0100
+++ libcpp/include/cpplib.h	2024-06-12 20:30:15.059835305 +0200
@@ -973,6 +973,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)' */
 };
@@ -1091,7 +1092,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-01-03 12:07:27.592378004 +0100
+++ libcpp/internal.h	2024-06-14 12:41:55.454827677 +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-01-03 12:07:27.324381759 +0100
+++ libcpp/directives.cc	2024-06-14 12:41:34.309113376 +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;
@@ -821,9 +823,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 +924,311 @@ 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;
+
+  /* Tell the lexer this is an embed directive.  */
+  pfile->state.in_directive = 3;
+
+  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");
+    }
+
+  const char *fname = parse_include (pfile, &angle_brackets, NULL, &params.loc);
+  if (!fname)
+    goto done;
+
+  if (!*fname)
+    {
+      cpp_error_with_line (pfile, CPP_DL_ERROR, params.loc, 0,
+			   "empty filename in #%s",
+			   pfile->directive->name);
+      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 +2392,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 +2480,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-01-03 12:07:27.310381955 +0100
+++ libcpp/expr.cc	2024-06-14 16:12:50.286505963 +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-03-14 14:07:34.308423858 +0100
+++ libcpp/files.cc	2024-06-14 12:47:03.649666800 +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
@@ -1060,12 +1096,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),
@@ -1179,6 +1215,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
@@ -1254,9 +1590,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;
@@ -1690,21 +2028,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)
     {
@@ -1713,6 +2054,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-04-30 08:58:21.983042975 +0200
+++ libcpp/init.cc	2024-06-12 20:32:49.485785205 +0200
@@ -435,6 +435,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
@@ -618,6 +619,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/macro.cc.jj	2024-03-14 14:07:34.323423650 +0100
+++ libcpp/macro.cc	2024-06-14 12:41:43.831984715 +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,10 @@ _cpp_builtin_macro_text (cpp_reader *pfi
 				    node->value.builtin == BT_HAS_INCLUDE_NEXT);
       break;
 
+    case BT_HAS_EMBED:
+      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-01-03 12:07:04.018708266 +0100
+++ gcc/doc/cppdiropts.texi	2024-06-13 17:48:03.104801300 +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/invoke.texi.jj	2024-06-06 08:20:53.895735712 +0200
+++ gcc/doc/invoke.texi	2024-06-13 17:43:32.542409280 +0200
@@ -716,6 +716,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-04 13:19:03.877602723 +0200
+++ gcc/gcc.cc	2024-06-13 16:16:09.823259761 +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-07 12:17:09.808966943 +0200
+++ gcc/genmatch.cc	2024-06-11 13:44:01.252898863 +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-01-03 11:51:31.896726124 +0100
+++ gcc/incpath.h	2024-06-11 13:18:02.987054680 +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-01-03 11:51:40.176611207 +0100
+++ gcc/incpath.cc	2024-06-11 13:43:25.315364541 +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-05-21 10:19:33.683538848 +0200
+++ gcc/c-family/c.opt	2024-06-11 14:07:01.177094022 +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-02-12 09:01:37.306073374 +0100
+++ gcc/c-family/c-opts.cc	2024-06-11 14:08:58.569571205 +0200
@@ -622,6 +622,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-13 14:23:58.465869177 +0200
+++ gcc/testsuite/c-c++-common/cpp/embed-1.c	2024-06-14 15:01:22.581766584 +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-13 19:04:34.836561842 +0200
+++ gcc/testsuite/c-c++-common/cpp/embed-2.c	2024-06-13 19:04:49.467366720 +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-13 19:05:02.255196178 +0200
+++ gcc/testsuite/c-c++-common/cpp/embed-3.c	2024-06-14 11:28:41.973286484 +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-13 19:37:07.859513146 +0200
+++ gcc/testsuite/c-c++-common/cpp/embed-4.c	2024-06-14 11:52:49.720670310 +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-13 20:01:52.524706619 +0200
+++ gcc/testsuite/c-c++-common/cpp/embed-5.c	2024-06-14 10:11:31.505619558 +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-14 10:08:59.020719387 +0200
+++ gcc/testsuite/c-c++-common/cpp/embed-6.c	2024-06-14 13:04:29.326538706 +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-14 12:17:01.417039893 +0200
+++ gcc/testsuite/c-c++-common/cpp/embed-7.c	2024-06-13 20:05:22.209908814 +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-14 13:03:45.960126279 +0200
+++ gcc/testsuite/c-c++-common/cpp/embed-8.c	2024-06-14 13:18:14.383360231 +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-14 13:17:37.185863947 +0200
+++ gcc/testsuite/c-c++-common/cpp/embed-9.c	2024-06-14 13:17:55.089621497 +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-14 13:59:33.277800418 +0200
+++ gcc/testsuite/c-c++-common/cpp/embed-10.c	2024-06-14 14:02:30.730398901 +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-14 15:11:04.989001117 +0200
+++ gcc/testsuite/c-c++-common/cpp/embed-11.c	2024-06-14 15:10:49.112212811 +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-14 16:23:24.374052200 +0200
+++ gcc/testsuite/c-c++-common/cpp/embed-12.c	2024-06-14 16:23:24.374052200 +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-dir/embed-1.inc.jj	2024-06-13 14:22:39.692922565 +0200
+++ gcc/testsuite/c-c++-common/cpp/embed-dir/embed-1.inc	2024-06-13 14:22:34.736988843 +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-14 13:01:34.747904086 +0200
+++ gcc/testsuite/c-c++-common/cpp/embed-dir/embed-3.c	2024-06-14 13:30:15.593593854 +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-14 12:15:57.689904183 +0200
+++ gcc/testsuite/c-c++-common/cpp/embed-dir/embed-4.c	2024-06-14 12:15:53.481961252 +0200
@@ -0,0 +1,3 @@
+/* { dg-do preprocess } */
+
+int i;
--- gcc/testsuite/c-c++-common/cpp/embed-dir/magna-carta.txt.jj	2024-06-13 16:00:25.208825359 +0200
+++ gcc/testsuite/c-c++-common/cpp/embed-dir/magna-carta.txt	2024-06-13 18:09:39.528510812 +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-13 16:20:51.087516792 +0200
+++ gcc/testsuite/gcc.dg/cpp/embed-1.c	2024-06-13 16:20:44.931598763 +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-13 18:33:07.705730411 +0200
+++ gcc/testsuite/gcc.dg/cpp/embed-2.c	2024-06-13 18:36:12.203269723 +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-13 18:36:21.735142596 +0200
+++ gcc/testsuite/gcc.dg/cpp/embed-3.c	2024-06-13 18:38:59.004045058 +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/g++.dg/cpp/embed-1.C.jj	2024-06-13 18:55:31.270810921 +0200
+++ gcc/testsuite/g++.dg/cpp/embed-1.C	2024-06-13 19:18:25.399484867 +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-13 18:56:47.301796954 +0200
+++ gcc/testsuite/g++.dg/cpp/embed-2.C	2024-06-13 19:18:38.338312301 +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-14 14:06:20.415290519 +0200
+++ gcc/testsuite/g++.dg/cpp/embed-3.C	2024-06-14 14:38:31.381189911 +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)
+      );
+}
