summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ExprConstant.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2019-06-25 01:45:26 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2019-06-25 01:45:26 +0000
commit7939ba08ab42922a00b7f1b7e4761c7f9cc51f0c (patch)
treedc56e20bcaa28f707ad3f87372eeefab7a8cd5a0 /clang/lib/AST/ExprConstant.cpp
parent079924b0b7fe5ee62ec9b9e4346544d147c781eb (diff)
downloadbcm5719-llvm-7939ba08ab42922a00b7f1b7e4761c7f9cc51f0c.tar.gz
bcm5719-llvm-7939ba08ab42922a00b7f1b7e4761c7f9cc51f0c.zip
[cxx2a] P1236R1: the validity of a left shift does not depend on the
value of the LHS operand. llvm-svn: 364265
Diffstat (limited to 'clang/lib/AST/ExprConstant.cpp')
-rw-r--r--clang/lib/AST/ExprConstant.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 3282bc0a0af..df7dd191782 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -2388,9 +2388,11 @@ static bool handleIntIntBinOp(EvalInfo &Info, const Expr *E, const APSInt &LHS,
if (SA != RHS) {
Info.CCEDiag(E, diag::note_constexpr_large_shift)
<< RHS << E->getType() << LHS.getBitWidth();
- } else if (LHS.isSigned()) {
+ } else if (LHS.isSigned() && !Info.getLangOpts().CPlusPlus2a) {
// C++11 [expr.shift]p2: A signed left shift must have a non-negative
// operand, and must not overflow the corresponding unsigned type.
+ // C++2a [expr.shift]p2: E1 << E2 is the unique value congruent to
+ // E1 x 2^E2 module 2^N.
if (LHS.isNegative())
Info.CCEDiag(E, diag::note_constexpr_lshift_of_negative) << LHS;
else if (LHS.countLeadingZeros() < SA)
OpenPOWER on IntegriCloud