================ @@ -0,0 +1,117 @@ +// RUN: %clang_cc1 -std=c++2a -verify %s + +struct A { + int a, b[3], c; + bool operator==(const A&) const = default; +}; + +constexpr auto a0 = A{0, 0, 3, 4, 5}; + +// expected-note@+1 {{evaluates to '{0, {0, 3, 4}, 5} == {1, {2, 3, 4}, 5}'}} +static_assert(a0 == A{1, {2, 3, 4}, 5}); // expected-error {{failed}} + +struct _arr { + const int b[3]; + constexpr bool operator==(const int rhs[3]) const { + for (unsigned i = 0; i < sizeof(b) / sizeof(int); i++) + if (b[i] != rhs[i]) + return false; + return true; + } +}; + +// TODO[seth] syntactically sort of valid but almost entirely unusuable +// (it's an int *, not an int [3] ) +// constexpr int _[3] = {...}; would work, but that's not piecewise substitutable +// maybe it's ok? I mean, not like we can do better really... +constexpr auto _ = (int[3]){2, 3, 4}; + +// output: '{{2, 3, 4}} == {0, 3, 4}' (the `{{` breaks VerifyDiagnosticConsumer::ParseDirective) ---------------- sethp wrote:
It didn't seem to like it; when I tried ``` // expected-note@+1 {{evaluates to '\{{2, 3, 4}\} == {0, 3, 4}'}} ``` here I got this output from `-verify`: ``` error: 'expected-error' diagnostics seen but not expected: File /home/seth/Code/src/github.com/llvm/llvm-project/clang/test/SemaCXX/static-assert-diagnostics.cpp Line 30: cannot find end ('}}') of expected string error: 'expected-note' diagnostics seen but not expected: File /home/seth/Code/src/github.com/llvm/llvm-project/clang/test/SemaCXX/static-assert-diagnostics.cpp Line 31: expression evaluates to '{{2, 3, 4}} == {0, 3, 4}' 2 errors generated. ``` I *think* I could use the `-re` mode, but then `{{` has _meaning_ so the output would be really obscured, something like `{{[{][{]}}` would be how to match `{{`, I think. My bad idea is to teach the parser to count opening braces instead, so a `expected-error {{{` looks for a `}}}` and ignores any `{{` or `}}` sequences, but I wanted to get this up before dealing with that particular sub-problem. https://github.com/llvm/llvm-project/pull/74852 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits