From c7e70c433efc6953dc3888b9fbf9f3512d7da2b0 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Thu, 2 Aug 2018 17:33:11 +0000 Subject: Vendor import of clang trunk r338536: https://llvm.org/svn/llvm-project/cfe/trunk@338536 --- test/Parser/cxx1z-fold-expressions.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'test/Parser/cxx1z-fold-expressions.cpp') diff --git a/test/Parser/cxx1z-fold-expressions.cpp b/test/Parser/cxx1z-fold-expressions.cpp index 342f11555fa78..93ee6f20ffc6d 100644 --- a/test/Parser/cxx1z-fold-expressions.cpp +++ b/test/Parser/cxx1z-fold-expressions.cpp @@ -60,3 +60,29 @@ template constexpr int nestedFoldOperator() { } static_assert(nestedFoldOperator<3, 1>() == 1); + +// A fold-expression is a primary-expression. +template +constexpr auto castSum(Ts... Args) { + return (T)(Args + ...).Value; // expected-error{{member reference base type 'int' is not a structure or union}} +} + +template +constexpr auto simpleSum(Ts... Args) { + return (... + Args).Value; // expected-error{{member reference base type 'int' is not a structure or union}} +} + +void prim() { + castSum(1, 2); + // expected-note@-1{{in instantiation of function template specialization}} + simpleSum(1, 2); + // expected-note@-1{{in instantiation of function template specialization}} + + struct Number { + int Value; + constexpr Number operator+(Number Rhs) const { return {Rhs.Value + Value}; } + }; + + static_assert(castSum(Number{1}, Number{2}) == 3); + static_assert(simpleSum(Number{1}, Number{2}) == 3); +} -- cgit v1.2.3