public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] libgcc: quote ARM macro parameters
@ 2015-10-03 16:51 Saleem Abdulrasool
  2015-10-03 18:29 ` Andreas Schwab
  0 siblings, 1 reply; 3+ messages in thread
From: Saleem Abdulrasool @ 2015-10-03 16:51 UTC (permalink / raw)
  To: gcc-patches; +Cc: Saleem Abdulrasool

For ARM EHABI _Unwind_{G,S}setIP are macros rather than proper functions as they
are extensions to the EHABI specification (though they are part of the Level 1
interface).  Quote the macro parameters, as otherwise, a complex parameter may
be ambiguously mis-expanded.
---
 libgcc/config/arm/unwind-arm.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libgcc/config/arm/unwind-arm.h b/libgcc/config/arm/unwind-arm.h
index f1f789c..3821c08 100644
--- a/libgcc/config/arm/unwind-arm.h
+++ b/libgcc/config/arm/unwind-arm.h
@@ -74,10 +74,10 @@ extern "C" {
     }
   /* Return the address of the instruction, not the actual IP value.  */
 #define _Unwind_GetIP(context) \
-  (_Unwind_GetGR (context, 15) & ~(_Unwind_Word)1)
+  (_Unwind_GetGR ((context), 15) & ~(_Unwind_Word)1)
 
 #define _Unwind_SetIP(context, val) \
-  _Unwind_SetGR (context, 15, val | (_Unwind_GetGR (context, 15) & 1))
+  _Unwind_SetGR ((context), 15, (val) | (_Unwind_GetGR ((context), 15) & 1))
 
 #ifdef __cplusplus
 }   /* extern "C" */
-- 
2.5.3

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] libgcc: quote ARM macro parameters
  2015-10-03 16:51 [PATCH] libgcc: quote ARM macro parameters Saleem Abdulrasool
@ 2015-10-03 18:29 ` Andreas Schwab
       [not found]   ` <CANXyDxuZ0XnZjbSTO8+6=6Pt2joA=m4X7zBW3yQN9Ma_hikXUQ@mail.gmail.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Schwab @ 2015-10-03 18:29 UTC (permalink / raw)
  To: Saleem Abdulrasool; +Cc: gcc-patches

Saleem Abdulrasool <compnerd@compnerd.org> writes:

> For ARM EHABI _Unwind_{G,S}setIP are macros rather than proper functions as they
> are extensions to the EHABI specification (though they are part of the Level 1
> interface).  Quote the macro parameters, as otherwise, a complex parameter may
> be ambiguously mis-expanded.
> ---
>  libgcc/config/arm/unwind-arm.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libgcc/config/arm/unwind-arm.h b/libgcc/config/arm/unwind-arm.h
> index f1f789c..3821c08 100644
> --- a/libgcc/config/arm/unwind-arm.h
> +++ b/libgcc/config/arm/unwind-arm.h
> @@ -74,10 +74,10 @@ extern "C" {
>      }
>    /* Return the address of the instruction, not the actual IP value.  */
>  #define _Unwind_GetIP(context) \
> -  (_Unwind_GetGR (context, 15) & ~(_Unwind_Word)1)
> +  (_Unwind_GetGR ((context), 15) & ~(_Unwind_Word)1)

How can that get mis-expanded (other than cheating with a macro that
expands to a comma)?

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] libgcc: quote ARM macro parameters
       [not found]   ` <CANXyDxuZ0XnZjbSTO8+6=6Pt2joA=m4X7zBW3yQN9Ma_hikXUQ@mail.gmail.com>
@ 2015-10-03 19:21     ` Andreas Schwab
  0 siblings, 0 replies; 3+ messages in thread
From: Andreas Schwab @ 2015-10-03 19:21 UTC (permalink / raw)
  To: Saleem Abdulrasool; +Cc: gcc-patches

Saleem Abdulrasool <compnerd@compnerd.org> writes:

> On Saturday, October 3, 2015, Andreas Schwab <schwab@linux-m68k.org> wrote:
>
>> Saleem Abdulrasool <compnerd@compnerd.org <javascript:;>> writes:
>>
>> > For ARM EHABI _Unwind_{G,S}setIP are macros rather than proper functions
>> as they
>> > are extensions to the EHABI specification (though they are part of the
>> Level 1
>> > interface).  Quote the macro parameters, as otherwise, a complex
>> parameter may
>> > be ambiguously mis-expanded.
>> > ---
>> >  libgcc/config/arm/unwind-arm.h | 4 ++--
>> >  1 file changed, 2 insertions(+), 2 deletions(-)
>> >
>> > diff --git a/libgcc/config/arm/unwind-arm.h
>> b/libgcc/config/arm/unwind-arm.h
>> > index f1f789c..3821c08 100644
>> > --- a/libgcc/config/arm/unwind-arm.h
>> > +++ b/libgcc/config/arm/unwind-arm.h
>> > @@ -74,10 +74,10 @@ extern "C" {
>> >      }
>> >    /* Return the address of the instruction, not the actual IP value.  */
>> >  #define _Unwind_GetIP(context) \
>> > -  (_Unwind_GetGR (context, 15) & ~(_Unwind_Word)1)
>> > +  (_Unwind_GetGR ((context), 15) & ~(_Unwind_Word)1)
>>
>> How can that get mis-expanded (other than cheating with a macro that
>> expands to a comma)?
>>
>
> Poor choice of words on my part.  It won't mis-expand, it may expand into
> an "ambiguous" statement (which will be diagnosed with a warning) if the
> argument is an expression in the sense of:
>
> a + b | 1

That cannot happen here, unless the caller already passes such an
expression.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-10-03 19:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-03 16:51 [PATCH] libgcc: quote ARM macro parameters Saleem Abdulrasool
2015-10-03 18:29 ` Andreas Schwab
     [not found]   ` <CANXyDxuZ0XnZjbSTO8+6=6Pt2joA=m4X7zBW3yQN9Ma_hikXUQ@mail.gmail.com>
2015-10-03 19:21     ` Andreas Schwab

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).