Re: [PATCH 01/11] Fix cpp_sys_macro_p with -ftrack-macro-expansion

2012-04-14 Thread Jason Merrill

OK.

Jason


Re: [PATCH 01/11] Fix cpp_sys_macro_p with -ftrack-macro-expansion

2012-04-14 Thread Dodji Seketeli
Jason Merrill  writes:

> On 04/10/2012 10:55 AM, Dodji Seketeli wrote:
>> +  if (CPP_OPTION (pfile, track_macro_expansion))
>
> I think this should check context->tokens_kind rather than the
> compiler flag.

OK.

Below is the updated patch that does that.

Tested and bootstrapped on x86_64-unknown-linux-gnu against trunk.

libcpp/

* macro.c (cpp_sys_macro_p):  Support -ftrack-macro-expansion.
---
 libcpp/macro.c |7 ++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/libcpp/macro.c b/libcpp/macro.c
index 54de3e3..4f8e52f 100644
--- a/libcpp/macro.c
+++ b/libcpp/macro.c
@@ -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;
 }
-- 
Dodji


Re: [PATCH 01/11] Fix cpp_sys_macro_p with -ftrack-macro-expansion

2012-04-11 Thread Jason Merrill

On 04/10/2012 10:55 AM, Dodji Seketeli wrote:

+  if (CPP_OPTION (pfile, track_macro_expansion))


I think this should check context->tokens_kind rather than the compiler 
flag.


Jason



[PATCH 01/11] Fix cpp_sys_macro_p with -ftrack-macro-expansion

2012-04-10 Thread Dodji Seketeli
Hello,

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.
---
 libcpp/macro.c |   10 +-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/libcpp/macro.c b/libcpp/macro.c
index 54de3e3..58a722c 100644
--- a/libcpp/macro.c
+++ b/libcpp/macro.c
@@ -2436,7 +2436,15 @@ 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 (CPP_OPTION (pfile, track_macro_expansion))
+{
+  if (pfile->context->c.mc)
+   node = pfile->context->c.mc->macro_node;
+}
+  else
+node = pfile->context->c.macro;
 
   return node && node->value.macro && node->value.macro->syshdr;
 }
-- 
Dodji