[PATCH] libsanitizer: remove -pedantic option

H.J. Lu hjl.tools@gmail.com
Fri Nov 5 15:22:20 GMT 2021


On Fri, Nov 5, 2021 at 8:00 AM Martin Liška <mliska@suse.cz> 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 = -Wall -W -Wno-unused-parameter -Wwrite-strings -Wno-long-long  -fPIC -fno-builtin -fno-exceptions -fno-rtti -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/hwasan/Makefile.in b/libsanitizer/hwasan/Makefile.in
> index 1729349e682..4c666ea622c 100644
> --- a/libsanitizer/hwasan/Makefile.in
> +++ b/libsanitizer/hwasan/Makefile.in
> @@ -404,7 +404,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 \
>         -funwind-tables -fvisibility=hidden -Wno-variadic-macros \
>         -fno-ipa-icf $(LIBSTDCXX_RAW_CXX_CXXFLAGS) -std=gnu++14 \
> diff --git a/libsanitizer/interception/Makefile.am b/libsanitizer/interception/Makefile.am
> index f7013b4ea94..dd111df65ae 100644
> --- a/libsanitizer/interception/Makefile.am
> +++ b/libsanitizer/interception/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
> -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
> +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
>   AM_CXXFLAGS += $(LIBSTDCXX_RAW_CXX_CXXFLAGS)
>   AM_CXXFLAGS += -std=gnu++14
>   AM_CXXFLAGS += $(EXTRA_CXXFLAGS)
> diff --git a/libsanitizer/interception/Makefile.in b/libsanitizer/interception/Makefile.in
> index 326ee9a1818..04c755063e0 100644
> --- a/libsanitizer/interception/Makefile.in
> +++ b/libsanitizer/interception/Makefile.in
> @@ -334,7 +334,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 $(LIBSTDCXX_RAW_CXX_CXXFLAGS) \
> diff --git a/libsanitizer/lsan/Makefile.am b/libsanitizer/lsan/Makefile.am
> index 6ff28ff5eea..e8201e07da5 100644
> --- a/libsanitizer/lsan/Makefile.am
> +++ b/libsanitizer/lsan/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
> -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
> +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
>   AM_CXXFLAGS += $(LIBSTDCXX_RAW_CXX_CXXFLAGS)
>   AM_CXXFLAGS += -std=gnu++14
>   AM_CXXFLAGS += $(EXTRA_CXXFLAGS)
> diff --git a/libsanitizer/lsan/Makefile.in b/libsanitizer/lsan/Makefile.in
> index 0ee0be6526e..cc30cdb1d96 100644
> --- a/libsanitizer/lsan/Makefile.in
> +++ b/libsanitizer/lsan/Makefile.in
> @@ -379,7 +379,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 $(LIBSTDCXX_RAW_CXX_CXXFLAGS) \
> diff --git a/libsanitizer/sanitizer_common/Makefile.am b/libsanitizer/sanitizer_common/Makefile.am
> index 57d7f02da92..b297ffde434 100644
> --- a/libsanitizer/sanitizer_common/Makefile.am
> +++ b/libsanitizer/sanitizer_common/Makefile.am
> @@ -4,7 +4,7 @@ AM_CPPFLAGS = -I $(top_srcdir)/include -I $(top_srcdir) -isystem $(top_srcdir)/i
>   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 @RPC_DEFS@
> -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
> +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
>   AM_CXXFLAGS += $(LIBSTDCXX_RAW_CXX_CXXFLAGS)
>   AM_CXXFLAGS += -std=gnu++14
>   AM_CXXFLAGS += $(EXTRA_CXXFLAGS)
> diff --git a/libsanitizer/sanitizer_common/Makefile.in b/libsanitizer/sanitizer_common/Makefile.in
> index ce24f6e7bc6..e754e642496 100644
> --- a/libsanitizer/sanitizer_common/Makefile.in
> +++ b/libsanitizer/sanitizer_common/Makefile.in
> @@ -371,7 +371,7 @@ AM_CPPFLAGS = -I $(top_srcdir)/include -I $(top_srcdir) -isystem $(top_srcdir)/i
>
>   # 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 $(LIBSTDCXX_RAW_CXX_CXXFLAGS) \
> diff --git a/libsanitizer/tsan/Makefile.am b/libsanitizer/tsan/Makefile.am
> index ae588a67df6..b8b3904b264 100644
> --- a/libsanitizer/tsan/Makefile.am
> +++ b/libsanitizer/tsan/Makefile.am
> @@ -4,7 +4,7 @@ AM_CPPFLAGS = -I $(top_srcdir) -I $(top_srcdir)/include
>   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
> -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
> +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
>   AM_CXXFLAGS += $(LIBSTDCXX_RAW_CXX_CXXFLAGS)
>   AM_CXXFLAGS += -std=gnu++14
>   AM_CXXFLAGS += $(EXTRA_CXXFLAGS)
> diff --git a/libsanitizer/tsan/Makefile.in b/libsanitizer/tsan/Makefile.in
> index 2781d2fcb3d..0beef717012 100644
> --- a/libsanitizer/tsan/Makefile.in
> +++ b/libsanitizer/tsan/Makefile.in
> @@ -408,7 +408,7 @@ AM_CPPFLAGS = -I $(top_srcdir) -I $(top_srcdir)/include
>
>   # 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 $(LIBSTDCXX_RAW_CXX_CXXFLAGS) \
> diff --git a/libsanitizer/ubsan/Makefile.am b/libsanitizer/ubsan/Makefile.am
> index d480f26adc0..c0741995cd1 100644
> --- a/libsanitizer/ubsan/Makefile.am
> +++ b/libsanitizer/ubsan/Makefile.am
> @@ -4,7 +4,7 @@ AM_CPPFLAGS = -I $(top_srcdir) -I $(top_srcdir)/include
>   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 -DPIC -DCAN_SANITIZE_UB=1 -DUBSAN_CAN_USE_CXXABI=1
> -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
> +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
>   AM_CXXFLAGS += $(LIBSTDCXX_RAW_CXX_CXXFLAGS)
>   AM_CXXFLAGS += -std=gnu++14
>   AM_CXXFLAGS += $(EXTRA_CXXFLAGS)
> diff --git a/libsanitizer/ubsan/Makefile.in b/libsanitizer/ubsan/Makefile.in
> index 4f4e4e579a2..96e93a1db92 100644
> --- a/libsanitizer/ubsan/Makefile.in
> +++ b/libsanitizer/ubsan/Makefile.in
> @@ -373,7 +373,7 @@ AM_CPPFLAGS = -I $(top_srcdir) -I $(top_srcdir)/include
>
>   # 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 $(LIBSTDCXX_RAW_CXX_CXXFLAGS) \
> --
> 2.33.1
>


-- 
H.J.


More information about the Gcc-patches mailing list