@@ -1,3 +1,9 @@
+2012-02-06 Diego Novillo <dnovillo@google.com>
+
+ * g++.dg/pph/x0string-escapes.h: New.
+ * g++.dg/pph/x1string-escapes.h: New.
+ * g++.dg/pph/x2string-escapes.cc: New.
+
2012-02-01 Lawrence Crowl <crowl@google.com>
* g++.dg/pph/x4structover1.cc: Mark fixed.
new file mode 100644
@@ -0,0 +1,7 @@
+#ifndef X0_STRING_ESCAPES_H
+#define X0_STRING_ESCAPES_H
+#define FOO(s) \
+ asm(".pushsection \".section_name\", \"MS\",%progbits,1\n" \
+ ".asciz \"" s "\"\n" \
+ ".popsection \n");
+#endif
new file mode 100644
@@ -0,0 +1,4 @@
+#ifndef X1_STRING_ESCAPES_H
+#define X1_STRING_ESCAPES_H
+#include "x0string-escapes.h"
+#endif
new file mode 100644
@@ -0,0 +1,9 @@
+#include "x1string-escapes.h"
+
+int foo(int);
+
+int foo(int i)
+{
+ FOO("name");
+ return i;
+}
@@ -1,3 +1,16 @@
+2012-02-06 Diego Novillo <dnovillo@google.com>
+
+ * directives.c (_cpp_clear_directive_state): New.
+ (end_directive): Call it.
+ (_cpp_save_directive_state): New.
+ (_cpp_restore_directive_state): New.
+ * internal.h (_cpp_clear_directive_state): Declare.
+ (_cpp_save_directive_state): Declare.
+ (_cpp_restore_directive_state): Declare.
+ * symtab.c (cpp_lt_replay): Call
+ _cpp_clear_directive_state, _cpp_save_directive_state and
+ _cpp_restore_directive_state.
+
2012-01-18 Diego Novillo <dnovillo@google.com>
* internal.h (cpp_in_primary_file): Move ...
@@ -311,11 +311,7 @@ end_directive (cpp_reader *pfile, int skip_line)
}
/* Restore state. */
- pfile->state.save_comments = ! CPP_OPTION (pfile, discard_comments);
- pfile->state.in_directive = 0;
- pfile->state.in_expression = 0;
- pfile->state.angled_headers = 0;
- pfile->directive = 0;
+ _cpp_clear_directive_state (pfile);
}
/* Prepare to handle the directive in pfile->directive. */
@@ -2606,3 +2602,39 @@ _cpp_init_directives (cpp_reader *pfile)
node->directive_index = i;
}
}
+
+/* Clear lexer directive state for PFILE. */
+
+void
+_cpp_clear_directive_state (cpp_reader *pfile)
+{
+ pfile->state.save_comments = ! CPP_OPTION (pfile, discard_comments);
+ pfile->state.in_directive = 0;
+ pfile->state.in_expression = 0;
+ pfile->state.angled_headers = 0;
+ pfile->directive = 0;
+}
+
+
+/* Save lexer directive state for PFILE on *DIRECTIVE_P and *STATE_P. */
+
+void
+_cpp_save_directive_state (cpp_reader *pfile,
+ const struct directive **directive_p,
+ struct lexer_state *state_p)
+{
+ memcpy (state_p, &pfile->state, sizeof (*state_p));
+ *directive_p = pfile->directive;
+}
+
+
+/* Restore lexer directive state for PFILE from *DIRECTIVE_P and *STATE_P. */
+
+void
+_cpp_restore_directive_state (cpp_reader *pfile,
+ const struct directive *directive_p,
+ struct lexer_state *state_p)
+{
+ memcpy (&pfile->state, state_p, sizeof (*state_p));
+ pfile->directive = directive_p;
+}
@@ -719,6 +719,12 @@ extern void _cpp_init_internal_pragmas (cpp_reader *);
extern void _cpp_do_file_change (cpp_reader *, enum lc_reason, const char *,
linenum_type, unsigned int);
extern void _cpp_pop_buffer (cpp_reader *);
+extern void _cpp_clear_directive_state (cpp_reader *);
+extern void _cpp_save_directive_state (cpp_reader *, const struct directive **,
+ struct lexer_state *);
+extern void _cpp_restore_directive_state (cpp_reader *,
+ const struct directive *,
+ struct lexer_state *);
/* In directives.c */
struct _cpp_dir_only_callbacks
@@ -825,6 +825,8 @@ void
cpp_lt_replay (cpp_reader *reader, cpp_idents_used* identifiers,
source_location *loc)
{
+ const struct directive *directive;
+ struct lexer_state state;
unsigned int i;
unsigned int num_entries = identifiers->num_entries;
cpp_ident_use *entries = identifiers->entries;
@@ -834,6 +836,12 @@ cpp_lt_replay (cpp_reader *reader, cpp_idents_used* identifiers,
/* Prevent the lexer from invalidating the tokens we've read so far. */
reader->keep_tokens++;
+ /* Clear the lexer state so it does not think that we are inside a
+ directive. When re-playing the symbol table, we are inside the
+ #include directive that brought in a PPH image. */
+ _cpp_save_directive_state (reader, &directive, &state);
+ _cpp_clear_directive_state (reader);
+
if (loc)
cpp_force_token_locations (reader, loc);
@@ -874,6 +882,9 @@ cpp_lt_replay (cpp_reader *reader, cpp_idents_used* identifiers,
cpp_stop_forcing_token_locations (reader);
free (buffer);
+
+ /* Restore the lexer state. */
+ _cpp_restore_directive_state (reader, directive, &state);
}
/* Destroy IDENTIFIERS captured. */