From 0569479efa2b65ce9e08e24d452d0619d60afd95 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 10 Nov 2016 18:04:06 +0100 Subject: [PATCH] mangle.c (mangle_decl): Only emit -Wc++1z-compat warnings for public or external symbols. * 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. From-SVN: r242042 --- gcc/cp/ChangeLog | 5 ++++ gcc/cp/mangle.c | 3 ++- gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/g++.dg/asan/asan_test.C | 2 +- gcc/testsuite/g++.dg/cpp1z/noexcept-type14.C | 26 ++++++++++++++++++++ 5 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp1z/noexcept-type14.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 49561fc6832..b19a236f215 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2016-11-10 Jakub Jelinek + + * mangle.c (mangle_decl): Only emit -Wc++1z-compat warnings for + public or external symbols. + 2016-11-09 Jakub Jelinek PR c++/78283 diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index 2dcec3b1968..be7b72b532e 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -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", diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 50281572ec5..7c131725f5a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-11-10 Jakub Jelinek + + * g++.dg/cpp1z/noexcept-type14.C: New test. + * g++.dg/asan/asan_test.C: Remove -Wno-c++1z-compat from dg-options. + 2016-11-10 James Greenhalgh * gcc.dg/torture/fp-int-convert.h (M_OK2): New, use it in diff --git a/gcc/testsuite/g++.dg/asan/asan_test.C b/gcc/testsuite/g++.dg/asan/asan_test.C index ba6f6a34e0b..5c24260b7fd 100644 --- a/gcc/testsuite/g++.dg/asan/asan_test.C +++ b/gcc/testsuite/g++.dg/asan/asan_test.C @@ -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 } } } diff --git a/gcc/testsuite/g++.dg/cpp1z/noexcept-type14.C b/gcc/testsuite/g++.dg/cpp1z/noexcept-type14.C new file mode 100644 index 00000000000..a6aeb1ce734 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/noexcept-type14.C @@ -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); +} -- 2.30.2