Debian Codegraph @

gcc/testsuite/g++.dg/warn/Wignored-qualifiers3.C

raw
1 // PR c++/107492
2 // { dg-do compile { target c++14 } }
3 // { dg-additional-options "-Wignored-qualifiers" }
4
5 // Here the 'const' matters, so don't warn.
6 template<typename T> struct S { };
7 template<> struct S<void(*)()> { };
8 template<> struct S<const void(*)()> { }; // { dg-bogus "ignored" }
9
10 template<typename T, typename U> constexpr bool is_same_v = false;
11 template<typename T> constexpr bool is_same_v<T, T> = true;
12
13 static_assert( ! is_same_v< void(*)(), const void(*)() >, ""); // { dg-bogus "ignored" }
14
15 // Here the 'const' matters as well -> don't warn.
16 auto g() -> const void (*)(); // { dg-bogus "ignored" }
17 auto g() -> const void (*)() { return nullptr; } // { dg-bogus "ignored" }
18
19 // Here as well.
20 const void (*h)() = static_cast<const void (*)()>(h); // { dg-bogus "ignored" }
21
22 // But let's keep the warning here.
23 const void f(); // { dg-warning "ignored" }
24 const void f() { } // { dg-warning "ignored" }