Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pavel Kryukov <kryukov@frtk.ru>
To: Simon Marchi <simon.marchi@polymtl.ca>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] Do not expand macros to 'defined'
Date: Wed, 16 Jan 2019 20:38:00 -0000	[thread overview]
Message-ID: <0E004E63-FE19-47E6-B6A7-C647B59F3ACB@frtk.ru> (raw)
In-Reply-To: <4943ce6216667607c40b630ecba6a4d1@polymtl.ca>

> which supposedly can handle this fine

Right, but not with '-Wall -Wextra -Werror' flags.
These pedantic options help us (a little) keeping C++ project portable
between compilers, although we do not intent to have this property on GDB integration.

--
Pavel

> 16 янв. 2019 г., в 23:02, Simon Marchi <simon.marchi@polymtl.ca> написал(а):
> 
>> On 2019-01-16 01:34, Павел Крюков wrote:
>> Expanding a macro which contains 'defined' PP keyword is UB.
>> sim/common/Changelog:
>> 2019-01-16  Pavel I. Kryukov  <kryukov@frtk.ru>
>>        * sim-arange.c: eliminate DEFINE_NON_INLINE_P
>> ---
>> sim/common/sim-arange.c | 11 +++--------
>> 1 file changed, 3 insertions(+), 8 deletions(-)
>> diff --git a/sim/common/sim-arange.c b/sim/common/sim-arange.c
>> index 6373b742ce8..b3488ab564a 100644
>> --- a/sim/common/sim-arange.c
>> +++ b/sim/common/sim-arange.c
>> @@ -32,10 +32,7 @@ along with this program.  If not, see
>> <http://www.gnu.org/licenses/>.  */
>> #include <string.h>
>> #endif
>> -#define DEFINE_INLINE_P (! defined (SIM_ARANGE_C_INCLUDED))
>> -#define DEFINE_NON_INLINE_P defined (SIM_ARANGE_C_INCLUDED)
>> -
>> -#if DEFINE_NON_INLINE_P
>> +#ifdef SIM_ARANGE_C_INCLUDED
>> /* Insert a range.  */
>> @@ -280,9 +277,7 @@ sim_addr_range_delete (ADDR_RANGE *ar,
>> address_word start, address_word end)
>>   build_search_tree (ar);
>> }
>> -#endif /* DEFINE_NON_INLINE_P */
>> -
>> -#if DEFINE_INLINE_P
>> +#else /* SIM_ARANGE_C_INCLUDED */
>> SIM_ARANGE_INLINE int
>> sim_addr_range_hit_p (ADDR_RANGE *ar, address_word addr)
>> @@ -301,4 +296,4 @@ sim_addr_range_hit_p (ADDR_RANGE *ar, address_word addr)
>>   return 0;
>> }
>> -#endif /* DEFINE_INLINE_P */
>> +#endif /* SIM_ARANGE_C_INCLUDED */
> 
> The patch LGTM, I agree these macros are not really needed.  But I am confused, does this actually fix your c++ build?  You mentioned you were using g++ (and therefore cpp), which supposedly can handle this fine:
> 
> https://gcc.gnu.org/onlinedocs/cpp/Defined.html
> 
> If so, what did the error look like?
> 
> Simon


  reply	other threads:[~2019-01-16 20:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-16  6:34 Павел Крюков
2019-01-16 20:02 ` Simon Marchi
2019-01-16 20:38   ` Pavel Kryukov [this message]
2019-01-16 21:11     ` Simon Marchi
2019-01-16 20:49   ` Andreas Schwab
2019-01-16 20:59     ` Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0E004E63-FE19-47E6-B6A7-C647B59F3ACB@frtk.ru \
    --to=kryukov@frtk.ru \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@polymtl.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox