Re: [PATCH] libsanitizer: remove -pedantic option

2021-11-05 Thread Martin Liška

On 11/5/21 16:29, Jakub Jelinek wrote:

On Fri, Nov 05, 2021 at 04:25:53PM +0100, Martin Liška wrote:

On 11/5/21 16:22, H.J. Lu wrote:

Should we add __extension__ here?


I tried doing that but it didn't help me with the warning.
Maybe I did something wrong?


Works for me just fine say on:
void foo ()
{
   int a = ({ int d = 1; d; });
   int b = __extension__ ({ int d = 1; d; });
}
-Wpedantic warning on line 3, none on line 4.  Add -D__extension__=
and it warns on both.

Jakub



Thank you both, it really work. I wrongly put the keyword to the first
statement in curly braces.

I'm going to suggest that to the upstream.

Cheers,
Martin


Re: [PATCH] libsanitizer: remove -pedantic option

2021-11-05 Thread H.J. Lu via Gcc-patches
On Fri, Nov 5, 2021 at 8:25 AM Martin Liška  wrote:
>
> On 11/5/21 16:22, H.J. Lu wrote:
> > Should we add __extension__ here?
>
> I tried doing that but it didn't help me with the warning.
> Maybe I did something wrong?

[hjl@gnu-cfl-2 tmp]$ cat y.cc
#include 

#define uptr uintptr_t

#  define GET_CURRENT_PC()\
   (__extension__ ({  \
  uptr pc;\
  asm("lea 0(%%rip), %0" : "=r"(pc)); \
  pc; \
}))

uptr
foo (void)
{
  return GET_CURRENT_PC ();
}
[hjl@gnu-cfl-2 tmp]$ gcc -S -O2 y.cc -pedantic
[hjl@gnu-cfl-2 tmp]$


-- 
H.J.


Re: [PATCH] libsanitizer: remove -pedantic option

2021-11-05 Thread Jakub Jelinek via Gcc-patches
On Fri, Nov 05, 2021 at 04:25:53PM +0100, Martin Liška wrote:
> On 11/5/21 16:22, H.J. Lu wrote:
> > Should we add __extension__ here?
> 
> I tried doing that but it didn't help me with the warning.
> Maybe I did something wrong?

Works for me just fine say on:
void foo ()
{
  int a = ({ int d = 1; d; });
  int b = __extension__ ({ int d = 1; d; });
}
-Wpedantic warning on line 3, none on line 4.  Add -D__extension__=
and it warns on both.

Jakub



Re: [PATCH] libsanitizer: remove -pedantic option

2021-11-05 Thread Martin Liška

On 11/5/21 16:22, H.J. Lu wrote:

Should we add __extension__ here?


I tried doing that but it didn't help me with the warning.
Maybe I did something wrong?

Cheers,
Martin


Re: [PATCH] libsanitizer: remove -pedantic option

2021-11-05 Thread H.J. Lu via Gcc-patches
On Fri, Nov 5, 2021 at 8:00 AM Martin Liška  wrote:
>
> The code uses intentionally braced-groups within expressions:
>
>  ({\

Should we add __extension__ here?

>uptr pc;\
>asm("lea 0(%%rip), %0" : "=r"(pc)); \
>pc; \
>  })
>
> And we emit gazillion of warnings now:
>
> /home/marxin/Programming/gcc/libsanitizer/tsan/tsan_interceptors_posix.cpp: 
> In function ‘int sigaction_impl(int, const 
> __sanitizer::__sanitizer_sigaction*, __sanitizer::__sanitizer_sigaction*)’:
> /home/marxin/Programming/gcc/libsanitizer/sanitizer_common/sanitizer_stacktrace.h:212:5:
>  warning: ISO C++ forbids braced-groups within expressions [-Wpedantic]
>212 | ({\
>| ^
> /home/marxin/Programming/gcc/libsanitizer/tsan/tsan_interceptors.h:44:26: 
> note: in expansion of macro ‘GET_CURRENT_PC’
> 44 |   UNUSED const uptr pc = GET_CURRENT_PC();
>|  ^~
>
> Ready to be installed?
> Thanks,
> Martin
>
> libsanitizer/ChangeLog:
>
> * asan/Makefile.am: Remove -pedantic option.
> * asan/Makefile.in: Likewise.
> * hwasan/Makefile.am: Likewise.
> * hwasan/Makefile.in: Likewise.
> * interception/Makefile.am: Likewise.
> * interception/Makefile.in: Likewise.
> * lsan/Makefile.am: Likewise.
> * lsan/Makefile.in: Likewise.
> * sanitizer_common/Makefile.am: Likewise.
> * sanitizer_common/Makefile.in: Likewise.
> * tsan/Makefile.am: Likewise.
> * tsan/Makefile.in: Likewise.
> * ubsan/Makefile.am: Likewise.
> * ubsan/Makefile.in: Likewise.
> ---
>   libsanitizer/asan/Makefile.am | 2 +-
>   libsanitizer/asan/Makefile.in | 2 +-
>   libsanitizer/hwasan/Makefile.am   | 2 +-
>   libsanitizer/hwasan/Makefile.in   | 2 +-
>   libsanitizer/interception/Makefile.am | 2 +-
>   libsanitizer/interception/Makefile.in | 2 +-
>   libsanitizer/lsan/Makefile.am | 2 +-
>   libsanitizer/lsan/Makefile.in | 2 +-
>   libsanitizer/sanitizer_common/Makefile.am | 2 +-
>   libsanitizer/sanitizer_common/Makefile.in | 2 +-
>   libsanitizer/tsan/Makefile.am | 2 +-
>   libsanitizer/tsan/Makefile.in | 2 +-
>   libsanitizer/ubsan/Makefile.am| 2 +-
>   libsanitizer/ubsan/Makefile.in| 2 +-
>   14 files changed, 14 insertions(+), 14 deletions(-)
>
> diff --git a/libsanitizer/asan/Makefile.am b/libsanitizer/asan/Makefile.am
> index 4f802f723d6..7270116cf71 100644
> --- a/libsanitizer/asan/Makefile.am
> +++ b/libsanitizer/asan/Makefile.am
> @@ -7,7 +7,7 @@ DEFS = -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS 
> -D__STDC_FORMAT_MACROS -D
>   if USING_MAC_INTERPOSE
>   DEFS += -DMAC_INTERPOSE_FUNCTIONS -DMISSING_BLOCKS_SUPPORT
>   endif
> -AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic 
> -Wno-long-long  -fPIC -fno-builtin -fno-exceptions -fno-rtti 
> -fomit-frame-pointer -funwind-tables -fvisibility=hidden -Wno-variadic-macros 
> -fno-ipa-icf
> +AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -Wno-long-long  
> -fPIC -fno-builtin -fno-exceptions -fno-rtti -fomit-frame-pointer 
> -funwind-tables -fvisibility=hidden -Wno-variadic-macros -fno-ipa-icf
>   AM_CXXFLAGS += $(LIBSTDCXX_RAW_CXX_CXXFLAGS)
>   AM_CXXFLAGS += -std=gnu++14
>   AM_CXXFLAGS += $(EXTRA_CXXFLAGS)
> diff --git a/libsanitizer/asan/Makefile.in b/libsanitizer/asan/Makefile.in
> index 528ab61312c..26971051b82 100644
> --- a/libsanitizer/asan/Makefile.in
> +++ b/libsanitizer/asan/Makefile.in
> @@ -416,7 +416,7 @@ AM_CPPFLAGS = -I $(top_srcdir)/include -I $(top_srcdir)
>
>   # May be used by toolexeclibdir.
>   gcc_version := $(shell @get_gcc_base_ver@ $(top_srcdir)/../gcc/BASE-VER)
> -AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic \
> +AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings \
> -Wno-long-long -fPIC -fno-builtin -fno-exceptions -fno-rtti \
> -fomit-frame-pointer -funwind-tables -fvisibility=hidden \
> -Wno-variadic-macros -fno-ipa-icf \
> diff --git a/libsanitizer/hwasan/Makefile.am b/libsanitizer/hwasan/Makefile.am
> index e12c0a0ce71..9fd39953789 100644
> --- a/libsanitizer/hwasan/Makefile.am
> +++ b/libsanitizer/hwasan/Makefile.am
> @@ -4,7 +4,7 @@ AM_CPPFLAGS = -I $(top_srcdir)/include -I $(top_srcdir)
>   gcc_version := $(shell @get_gcc_base_ver@ $(top_srcdir)/../gcc/BASE-VER)
>
>   DEFS = -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS 
> -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DCAN_SANITIZE_UB=0 
> -DHWASAN_WITH_INTERCEPTORS=1
> -AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic 
> -Wno-long-long  -fPIC -fno-builtin -fno-exceptions -fno-rtti -funwind-tables 
> -fvisibility=hidden -Wno-variadic-macros -fno-ipa-icf
> +AM_CXXFLAGS =