Debian Codegraph @

gcc/testsuite/g++.dg/diagnostic/aggr-init1.C

raw
1 // PR c++/116634
2 // { dg-do compile { target c++11 } }
3 // { dg-additional-options -fpermissive }
4
5 namespace std {
6 using size_t = decltype(sizeof(42));
7 }
8
9 class ConstString final {
10 public:
11 constexpr ConstString() noexcept: buf(), len(0) {}
12 template<int N>
13 constexpr ConstString(const char (&a)[N]): buf(a), len(N - 1) {}
14 constexpr ConstString(const ConstString &c1): buf(c1.buf), len(static_cast<int>(c1.len)) {}
15
16 private:
17 const char* buf;
18 int len;
19 };
20
21 template<int N>
22 struct Any final {
23 constexpr
24 Any(ConstString (&&_vec)[N]) noexcept: vec(_vec){} // { dg-warning "array" }
25
26 ConstString vec[N];
27 };
28
29 template<int... N1>
30 constexpr static
31 auto Any_of(const char (&...c1)[N1]) -> Any<static_cast<int>(sizeof...(N1))> {
32 return {{ConstString(c1)...}};
33 }
34
35 int main() {
36 constexpr static const auto aa1 = Any_of("abcd", "def"); // { dg-message {"abcd", "def"} }
37 }