Fix cpp_sys_macro_p with -ftrack-macro-expansion
authorDodji Seketeli <dodji@redhat.com>
Mon, 30 Apr 2012 11:41:08 +0000 (11:41 +0000)
committerDodji Seketeli <dodji@gcc.gnu.org>
Mon, 30 Apr 2012 11:41:08 +0000 (13:41 +0200)
cpp_sys_macro_p crashes when -ftrack-macro-expansion is on.  The issue
can be reproduced by running the tests:

    runtest --tool gcc --tool_opts="-ftrack-macro-expansion" cpp.exp=sysmac1.c
    runtest --tool gcc --tool_opts="-ftrack-macro-expansion" cpp.exp=sysmac2.c

This is because it just doesn't support that mode.  Fixed thus.
Tested and bootstrapped on x86_64-unknown-linux-gnu against trunk.

Note that the bootstrap with -ftrack-macro-expansion turned on
exhibits other separate issues that are addressed in subsequent
patches.  This patch just fixes one class of problems.

The patch does pass bootstrap with -ftrack-macro-expansion turned off,
though.

libcpp/

* macro.c (cpp_sys_macro_p):  Support -ftrack-macro-expansion.

From-SVN: r186965

libcpp/ChangeLog
libcpp/macro.c

index 4b66c84174d4eeb9375df404b1fe7dff1bec1101..c4f7c5af01a69eaaf344fccf9b79d78a27e272fa 100644 (file)
@@ -1,3 +1,8 @@
+2012-04-30  Dodji Seketeli  <dodji@redhat.com>
+
+       Fix cpp_sys_macro_p with -ftrack-macro-expansion
+       * macro.c (cpp_sys_macro_p):  Support -ftrack-macro-expansion.
+
 2012-04-29  Dodji Seketeli  <dodji@redhat.com>
 
        * lex.c (lex_raw_string): Change C++ style comments into C style
index 54de3e3fc0d939f2318bde97d75df31c185adfb9..4f8e52f22cfbb12856acf25c78b749b5f909fe9c 100644 (file)
@@ -2436,7 +2436,12 @@ cpp_get_token_with_location (cpp_reader *pfile, source_location *loc)
 int
 cpp_sys_macro_p (cpp_reader *pfile)
 {
-  cpp_hashnode *node = pfile->context->c.macro;
+  cpp_hashnode *node = NULL;
+
+  if (pfile->context->tokens_kind == TOKENS_KIND_EXTENDED)
+    node = pfile->context->c.mc->macro_node;
+  else
+    node = pfile->context->c.macro;
 
   return node && node->value.macro && node->value.macro->syshdr;
 }