This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH, committed] PPC405 atomic support (PR target/21760)


Geoffrey Keating wrote:
> David Edelsohn <dje@watson.ibm.com> writes:
> 
> 
>>>>>>>Andreas Schwab writes:
>>
>>>>+ /* If configured for PPC405, support PPC405CR Erratum77.  */
>>>>+ #define PPC405_CPU_DEFAULT ("405")
>>>>+ #if #TARGET_CPU_DEFAULT == #PPC405_CPU_DEFAULT
>>
>>Andreas> What is this expression supposed to do?  It doesn't match
>>anything defined by C89.
>>
>>	The expression is comparing the stringified value of the macros.
> 
> 
> I'm pretty sure that doesn't work, and in fact should be an error

It doesn't.  However, that is being masked, because # is not the
stringification operator in #if; only in #define.  If David had written

#define PPC405_CPU_DEFAULT ("405")
#define TARGET_CPU_DEFAULT ((char *) 0)
#define S(x) S_(x)
#define S_(x) #x
#if S(PPC405_CPU_DEFAULT) == S(TARGET_CPU_DEFAULT)
// yada yada
#endif

then he would have seen

$ gcc -fsyntax-only test.c
test.c:5:25: token ""(\"405\")"" is not valid in preprocessor expressions

# in an #if expression triggers one of our least useful extensions,
preprocessor assertions.  Both halves of the == will evaluate to zero, no
matter what the macros are defined to.  Sadly, we don't diagnose the use of an
extension here (patches welcome).

zw


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]