[PATCH] D36101: Fix usage of right shift operator in fold expressions

Blitz Rakete via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 31 12:26:42 PDT 2017


Rakete1111 created this revision.

The right shift operator was not seen as a valid operator in a fold expression, which is PR32563.


https://reviews.llvm.org/D36101

Files:
  lib/Parse/ParseExpr.cpp
  test/CXX/expr/expr.prim/expr.prim.fold/p2.cpp


Index: test/CXX/expr/expr.prim/expr.prim.fold/p2.cpp
===================================================================
--- test/CXX/expr/expr.prim/expr.prim.fold/p2.cpp
+++ test/CXX/expr/expr.prim/expr.prim.fold/p2.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++1z -verify %s
+
+// PR32563
+template<typename... Ts>
+constexpr int right_shift(int value, Ts... args) {
+  return (value >> ... >> args); // expected-no-diagnostics
+}
+
+void test_folds() {
+  static_assert(right_shift(10, 2) == 2);
+}
+
Index: lib/Parse/ParseExpr.cpp
===================================================================
--- lib/Parse/ParseExpr.cpp
+++ lib/Parse/ParseExpr.cpp
@@ -270,7 +270,7 @@
   return Level > prec::Unknown && Level != prec::Conditional;
 }
 static bool isFoldOperator(tok::TokenKind Kind) {
-  return isFoldOperator(getBinOpPrecedence(Kind, false, true));
+  return isFoldOperator(getBinOpPrecedence(Kind, true, true));
 }
 
 /// \brief Parse a binary expression that starts with \p LHS and has a


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36101.108966.patch
Type: text/x-patch
Size: 1005 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170731/60ec36d7/attachment.bin>


More information about the cfe-commits mailing list