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: [C++ PATCH] Only warn with -Wc++1z-compat about mangling of visible symbols


OK.

On Thu, Nov 10, 2016 at 8:52 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> It seems -Wabi/-Wc++1z-compat warns about mangling changes even for symbols that are
> not visible outside of its TU (so likely only inline asm or tools
> looking at .symtab STB_LOCAL symbols would notice).  Perhaps that is fine
> for -Wabi that isn't enabled in -Wall/-Wextra, but -Wc++1z-compat is, and
> I think most of the users don't really care about mangling of those symbols.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2016-11-10  Jakub Jelinek  <jakub@redhat.com>
>
>         * mangle.c (mangle_decl): Only emit -Wc++1z-compat warnings for
>         public or external symbols.
>
>         * g++.dg/cpp1z/noexcept-type14.C: New test.
>         * g++.dg/asan/asan_test.C: Remove -Wno-c++1z-compat from dg-options.
>
> --- gcc/cp/mangle.c.jj  2016-11-09 23:55:59.000000000 +0100
> +++ gcc/cp/mangle.c     2016-11-10 10:14:26.914059686 +0100
> @@ -3836,7 +3836,8 @@ mangle_decl (const tree decl)
>      }
>    SET_DECL_ASSEMBLER_NAME (decl, id);
>
> -  if (G.need_cxx1z_warning)
> +  if (G.need_cxx1z_warning
> +      && (TREE_PUBLIC (decl) || DECL_REALLY_EXTERN (decl)))
>      warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wc__1z_compat,
>                 "mangled name for %qD will change in C++17 because the "
>                 "exception specification is part of a function type",
> --- gcc/testsuite/g++.dg/cpp1z/noexcept-type14.C.jj     2016-11-10 10:14:42.898857481 +0100
> +++ gcc/testsuite/g++.dg/cpp1z/noexcept-type14.C        2016-11-10 10:22:46.412741092 +0100
> @@ -0,0 +1,26 @@
> +// { dg-do compile { target c++11 } }
> +// { dg-options "-Wall" }
> +
> +#define A asm volatile ("" : : : "memory")
> +void foo () throw () {}
> +extern void f1 (decltype (foo) *);     // { dg-bogus "mangled name" }
> +void f2 (decltype (foo) *);            // { dg-bogus "mangled name" }
> +extern void f3 (decltype (foo) *);     // { dg-warning "mangled name" "" { target c++14_down } }
> +void f4 (decltype (foo) *);            // { dg-warning "mangled name" "" { target c++14_down } }
> +void f5 (decltype (foo) *) { A; }      // { dg-warning "mangled name" "" { target c++14_down } }
> +static void f6 (decltype (foo) *) { A; }// { dg-bogus "mangled name" }
> +namespace N {
> +void f7 (decltype (foo) *) { A; }      // { dg-warning "mangled name" "" { target c++14_down } }
> +}
> +namespace {
> +void f8 (decltype (foo) *) { A; }      // { dg-bogus "mangled name" }
> +}
> +void bar ()
> +{
> +  f3 (foo);
> +  f4 (foo);
> +  f5 (foo);
> +  f6 (foo);
> +  N::f7 (foo);
> +  f8 (foo);
> +}
> --- gcc/testsuite/g++.dg/asan/asan_test.C.jj    2016-11-10 00:00:00.000000000 +0100
> +++ gcc/testsuite/g++.dg/asan/asan_test.C       2016-11-10 13:28:55.348073019 +0100
> @@ -2,7 +2,7 @@
>  // { dg-skip-if "" { *-*-* } { "*" } { "-O2" } }
>  // { dg-skip-if "" { *-*-* } { "-flto" } { "" } }
>  // { dg-additional-sources "asan_globals_test-wrapper.cc" }
> -// { dg-options "-std=c++11 -fsanitize=address -fno-builtin -Wall -Wno-c++1z-compat -Werror -g -DASAN_UAR=0 -DASAN_HAS_EXCEPTIONS=1 -DASAN_HAS_BLACKLIST=0 -DSANITIZER_USE_DEJAGNU_GTEST=1 -lasan -lpthread -ldl" }
> +// { dg-options "-std=c++11 -fsanitize=address -fno-builtin -Wall -Werror -g -DASAN_UAR=0 -DASAN_HAS_EXCEPTIONS=1 -DASAN_HAS_BLACKLIST=0 -DSANITIZER_USE_DEJAGNU_GTEST=1 -lasan -lpthread -ldl" }
>  // { dg-additional-options "-DASAN_NEEDS_SEGV=1" { target { ! arm*-*-* } } }
>  // { dg-additional-options "-DASAN_LOW_MEMORY=1 -DASAN_NEEDS_SEGV=0" { target arm*-*-* } }
>  // { dg-additional-options "-DASAN_AVOID_EXPENSIVE_TESTS=1" { target { ! run_expensive_tests } } }
>
>         Jakub


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