diff mbox

Patches to enable -ftrack-macro-expansion by default

Message ID m38vhb3n1j.fsf@redhat.com
State New
Headers show

Commit Message

Dodji Seketeli May 1, 2012, 4:04 p.m. UTC
Jason Merrill <jason@redhat.com> writes:

> On 05/01/2012 05:36 AM, Dodji Seketeli wrote:
>>     pfile->context = XNEW (cpp_context);
>> +  memset (pfile->context, 0, sizeof (cpp_context));
>
> You can use XCNEW instead of XNEW + memset.
>
> OK with that change.

Thank you.

Here is the patch I will commit when Uros confirms that it fixes the
problem for him on alpha.

libcpp/

	* directives.c (destringize_and_run): Properly initialize the new
	context.
	* macro.c (_cpp_pop_context): Assert that we shouldn't try to pop
	the initial base context, which has the same life time as the
	current instance of cpp_file.
---
 libcpp/directives.c |    5 +----
 libcpp/macro.c      |    4 ++++
 2 files changed, 5 insertions(+), 4 deletions(-)

Comments

Uros Bizjak May 2, 2012, 4:43 p.m. UTC | #1
On Tue, May 1, 2012 at 6:04 PM, Dodji Seketeli <dodji@redhat.com> wrote:

>>>     pfile->context = XNEW (cpp_context);
>>> +  memset (pfile->context, 0, sizeof (cpp_context));
>>
>> You can use XCNEW instead of XNEW + memset.
>>
>> OK with that change.
>
> Thank you.
>
> Here is the patch I will commit when Uros confirms that it fixes the
> problem for him on alpha.

Yes, the patch works OK on alpha and fixes the ICE in macro-4.c test.

Thanks,
Uros.
Dodji Seketeli May 2, 2012, 4:56 p.m. UTC | #2
Uros Bizjak <ubizjak@gmail.com> writes:

> On Tue, May 1, 2012 at 6:04 PM, Dodji Seketeli <dodji@redhat.com> wrote:
>
>>>>     pfile->context = XNEW (cpp_context);
>>>> +  memset (pfile->context, 0, sizeof (cpp_context));
>>>
>>> You can use XCNEW instead of XNEW + memset.
>>>
>>> OK with that change.
>>
>> Thank you.
>>
>> Here is the patch I will commit when Uros confirms that it fixes the
>> problem for him on alpha.
>
> Yes, the patch works OK on alpha and fixes the ICE in macro-4.c test.

Thanks.  I have committed the patch to the mainline, at SVN revision
r187054.
diff mbox

Patch

diff --git a/libcpp/directives.c b/libcpp/directives.c
index 0510c6e..e46280e 100644
--- a/libcpp/directives.c
+++ b/libcpp/directives.c
@@ -1741,10 +1741,7 @@  destringize_and_run (cpp_reader *pfile, const cpp_string *in)
   saved_cur_token = pfile->cur_token;
   saved_cur_run = pfile->cur_run;
 
-  pfile->context = XNEW (cpp_context);
-  pfile->context->c.macro = 0;
-  pfile->context->prev = 0;
-  pfile->context->next = 0;
+  pfile->context = XCNEW (cpp_context);
 
   /* Inline run_directive, since we need to delay the _cpp_pop_buffer
      until we've read all of the tokens that we want.  */
diff --git a/libcpp/macro.c b/libcpp/macro.c
index ab3e8f6..c4e2a23 100644
--- a/libcpp/macro.c
+++ b/libcpp/macro.c
@@ -2152,6 +2152,10 @@  _cpp_pop_context (cpp_reader *pfile)
 {
   cpp_context *context = pfile->context;
 
+  /* We should not be popping the base context.  */
+  if (context == &pfile->base_context)
+    abort ();
+
   if (context->c.macro)
     {
       cpp_hashnode *macro;