diff options
Diffstat (limited to 'clang/test/Parser/cxx1z-fold-expressions.cpp')
| -rw-r--r-- | clang/test/Parser/cxx1z-fold-expressions.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/test/Parser/cxx1z-fold-expressions.cpp b/clang/test/Parser/cxx1z-fold-expressions.cpp index a908311ea31..03063858323 100644 --- a/clang/test/Parser/cxx1z-fold-expressions.cpp +++ b/clang/test/Parser/cxx1z-fold-expressions.cpp @@ -9,12 +9,19 @@ int k1 = (1 + ... + 2); // expected-error {{does not contain any unexpanded para int k2 = (1 + ...); // expected-error {{does not contain any unexpanded parameter packs}} int k3 = (... + 2); // expected-error {{does not contain any unexpanded parameter packs}} +struct A { A(int); friend A operator+(A, A); A operator-(A); A operator()(A); A operator[](A); }; +A operator*(A, A); + template<int ...N> void bad1() { (N + ... + N); } // expected-error {{unexpanded parameter packs in both operands}} // FIXME: it would be reasonable to support this as an extension. template<int ...N> void bad2() { (2 * N + ... + 1); } // expected-error {{expression not permitted as operand}} template<int ...N> void bad3() { (2 + N * ... * 1); } // expected-error {{expression not permitted as operand}} template<int ...N, int ...M> void bad4(int (&...x)[N]) { (N + M * ... * 1); } // expected-error {{expression not permitted as operand}} template<int ...N, int ...M> void fixed4(int (&...x)[N]) { ((N + M) * ... * 1); } +template<typename ...T> void bad4a(T ...t) { (t * 2 + ... + 1); } // expected-error {{expression not permitted as operand}} +template<int ...N> void bad4b() { (A(0) + A(N) + ...); } // expected-error {{expression not permitted as operand}} +template<int ...N> void bad4c() { (A(0) - A(N) + ...); } // expected-error {{expression not permitted as operand}} +template<int ...N> void bad4d() { (A(0)(A(0)) + ... + A(0)[A(N)]); } // Parens are mandatory. template<int ...N> void bad5() { N + ...; } // expected-error {{expected expression}} expected-error +{{}} |

