diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp index 72789d9d34814..6ad75d4e034a9 100644 --- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -1468,7 +1468,7 @@ bool ByteCodeExprGen::VisitCompoundAssignOperator( std::optional LHSComputationT = classify(E->getComputationLHSType()); std::optional LT = classify(LHS->getType()); - std::optional RT = classify(E->getComputationResultType()); + std::optional RT = classify(RHS->getType()); std::optional ResultT = classify(E->getType()); if (!LT || !RT || !ResultT || !LHSComputationT) diff --git a/clang/test/AST/Interp/shifts.cpp b/clang/test/AST/Interp/shifts.cpp index cf71e7145c274..e5201b3f8bbef 100644 --- a/clang/test/AST/Interp/shifts.cpp +++ b/clang/test/AST/Interp/shifts.cpp @@ -188,3 +188,12 @@ namespace shifts { // ref-cxx17-error {{not an integral constant expression}} \ // ref-cxx17-note {{in call to 'foo(2)'}} }; + +namespace LongInt { + constexpr int f() { + int a = 1; + a <<= (long)0; + return 1; + } + static_assert(f() == 1, ""); +};