aboutsummaryrefslogtreecommitdiffstats
path: root/test/Parser/cxx1z-fold-expressions.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2018-08-02 17:33:11 +0000
committerDimitry Andric <dim@FreeBSD.org>2018-08-02 17:33:11 +0000
commitc7e70c433efc6953dc3888b9fbf9f3512d7da2b0 (patch)
tree27425930fc0c91650a7f3527fcac8e0f92907b90 /test/Parser/cxx1z-fold-expressions.cpp
parent486754660bb926339aefcf012a3f848592babb8b (diff)
downloadsrc-c7e70c433efc6953dc3888b9fbf9f3512d7da2b0.tar.gz
src-c7e70c433efc6953dc3888b9fbf9f3512d7da2b0.zip
Vendor import of clang trunk r338536:vendor/clang/clang-trunk-r338536
Notes
Notes: svn path=/vendor/clang/dist/; revision=337139 svn path=/vendor/clang/clang-trunk-r338536/; revision=337140; tag=vendor/clang/clang-trunk-r338536
Diffstat (limited to 'test/Parser/cxx1z-fold-expressions.cpp')
-rw-r--r--test/Parser/cxx1z-fold-expressions.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/Parser/cxx1z-fold-expressions.cpp b/test/Parser/cxx1z-fold-expressions.cpp
index 342f11555fa7..93ee6f20ffc6 100644
--- a/test/Parser/cxx1z-fold-expressions.cpp
+++ b/test/Parser/cxx1z-fold-expressions.cpp
@@ -60,3 +60,29 @@ template <int... N> constexpr int nestedFoldOperator() {
}
static_assert(nestedFoldOperator<3, 1>() == 1);
+
+// A fold-expression is a primary-expression.
+template <typename T, typename... Ts>
+constexpr auto castSum(Ts... Args) {
+ return (T)(Args + ...).Value; // expected-error{{member reference base type 'int' is not a structure or union}}
+}
+
+template <typename... Ts>
+constexpr auto simpleSum(Ts... Args) {
+ return (... + Args).Value; // expected-error{{member reference base type 'int' is not a structure or union}}
+}
+
+void prim() {
+ castSum<int>(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<long>(Number{1}, Number{2}) == 3);
+ static_assert(simpleSum(Number{1}, Number{2}) == 3);
+}