diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-10-31 20:29:22 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-10-31 20:29:22 +0000 |
| commit | fd62945d36bbf71f42f6c08fea144200ad90a0fb (patch) | |
| tree | 36ad2d6defca6cce681fe2fd484205c18444c78a /clang/test | |
| parent | 7cb25a888ce53c288de9369c5b98082b4ea5ec26 (diff) | |
| download | bcm5719-llvm-fd62945d36bbf71f42f6c08fea144200ad90a0fb.tar.gz bcm5719-llvm-fd62945d36bbf71f42f6c08fea144200ad90a0fb.zip | |
Fix usage of right shift operator in fold expressions
The right shift operator was not seen as a valid operator in a fold expression, which is PR32563.
Patch by Nicolas Lesser ("Blitz Rakete")!
llvm-svn: 317032
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/Parser/cxx1z-fold-expressions.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/test/Parser/cxx1z-fold-expressions.cpp b/clang/test/Parser/cxx1z-fold-expressions.cpp index b1f7318e410..342f11555fa 100644 --- a/clang/test/Parser/cxx1z-fold-expressions.cpp +++ b/clang/test/Parser/cxx1z-fold-expressions.cpp @@ -43,3 +43,20 @@ template<typename ...T> void as_operand_of_cast(int a, T ...t) { (int)(undeclared_junk + ...) + // expected-error {{undeclared}} (int)(a + ...); // expected-error {{does not contain any unexpanded}} } + +// fold-operator can be '>' or '>>'. +template <int... N> constexpr bool greaterThan() { return (N > ...); } +template <int... N> constexpr int rightShift() { return (N >> ...); } + +static_assert(greaterThan<2, 1>()); +static_assert(rightShift<10, 1>() == 5); + +template <auto V> constexpr auto Identity = V; + +// Support fold operators within templates. +template <int... N> constexpr int nestedFoldOperator() { + return Identity<(Identity<0> >> ... >> N)> + + Identity<(N >> ... >> Identity<0>)>; +} + +static_assert(nestedFoldOperator<3, 1>() == 1); |

