- /* Since the handler below doesn't get the line number, that it
- might need for diagnostics, make sure it has the right
- numbers in place. */
- if (pfile->cb.line_change)
- (*pfile->cb.line_change) (pfile, pragma_token, false);
- (*p->u.handler) (pfile);
+ if (p->is_internal || !CPP_OPTION (pfile, defer_pragmas))
+ {
+ /* Since the handler below doesn't get the line number, that it
+ might need for diagnostics, make sure it has the right
+ numbers in place. */
+ if (pfile->cb.line_change)
+ (*pfile->cb.line_change) (pfile, pragma_token, false);
+ /* Never expand macros if handling a deferred pragma, since
+ the macro definitions now applicable may be different
+ from those at the point the pragma appeared. */
+ if (p->allow_expansion && !pfile->state.in_deferred_pragma)
+ pfile->state.prevent_expansion--;
+ (*p->u.handler) (pfile);
+ if (p->allow_expansion && !pfile->state.in_deferred_pragma)
+ pfile->state.prevent_expansion++;
+ }
+ else
+ {
+ /* Squirrel away the pragma text. Pragmas are
+ newline-terminated. */
+ const uchar *line_end;
+ uchar *s;
+ cpp_string body;
+ cpp_token *ptok;
+
+ line_end = ustrchr (line_start, '\n');
+
+ body.len = (line_end - line_start) + 1;
+ s = _cpp_unaligned_alloc (pfile, body.len + 1);
+ memcpy (s, line_start, body.len);
+ s[body.len] = '\0';
+ body.text = s;
+
+ /* Create a CPP_PRAGMA token. */
+ ptok = &pfile->directive_result;
+ ptok->src_loc = pragma_token->src_loc;
+ ptok->type = CPP_PRAGMA;
+ ptok->flags = pragma_token->flags | NO_EXPAND;
+ ptok->val.str = body;
+ }