Skip to content

Commit 5bb9c08

Browse files
committed
[clang][Interp] Reject compound assign operators pre-C++14
1 parent 69cd2d2 commit 5bb9c08

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

clang/lib/AST/Interp/ByteCodeExprGen.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1834,6 +1834,9 @@ bool ByteCodeExprGen<Emitter>::VisitCompoundAssignOperator(
18341834
std::optional<PrimType> RT = classify(RHS->getType());
18351835
std::optional<PrimType> ResultT = classify(E->getType());
18361836

1837+
if (!Ctx.getLangOpts().CPlusPlus14)
1838+
return this->visit(RHS) && this->visit(LHS) && this->emitError(E);
1839+
18371840
if (!LT || !RT || !ResultT || !LHSComputationT)
18381841
return false;
18391842

clang/test/SemaCXX/for-range-examples.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
2+
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -fexperimental-new-constant-interpreter
23

34
namespace value_range_detail {
45
template<typename T>

clang/test/SemaCXX/integer-overflow.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
// RUN: %clang_cc1 %s -verify -fsyntax-only -std=gnu++98 -triple x86_64-pc-linux-gnu
22
// RUN: %clang_cc1 %s -verify -fsyntax-only -std=gnu++2a -triple x86_64-pc-linux-gnu
33

4+
// RUN: %clang_cc1 %s -verify -fsyntax-only -std=gnu++98 -triple x86_64-pc-linux-gnu -fexperimental-new-constant-interpreter
5+
// RUN: %clang_cc1 %s -verify -fsyntax-only -std=gnu++2a -triple x86_64-pc-linux-gnu -fexperimental-new-constant-interpreter
6+
7+
48
typedef unsigned long long uint64_t;
59
typedef unsigned int uint32_t;
610

0 commit comments

Comments
 (0)