File tree 4 files changed +19
-8
lines changed 4 files changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -2244,7 +2244,7 @@ template <class Emitter> bool ByteCodeExprGen<Emitter>::discard(const Expr *E) {
2244
2244
template <class Emitter >
2245
2245
bool ByteCodeExprGen<Emitter>::delegate(const Expr *E) {
2246
2246
if (E->containsErrors ())
2247
- return false ;
2247
+ return this -> emitError (E) ;
2248
2248
2249
2249
// We're basically doing:
2250
2250
// OptionScope<Emitter> Scope(this, DicardResult, Initializing);
@@ -2254,7 +2254,7 @@ bool ByteCodeExprGen<Emitter>::delegate(const Expr *E) {
2254
2254
2255
2255
template <class Emitter > bool ByteCodeExprGen<Emitter>::visit(const Expr *E) {
2256
2256
if (E->containsErrors ())
2257
- return false ;
2257
+ return this -> emitError (E) ;
2258
2258
2259
2259
if (E->getType ()->isVoidType ())
2260
2260
return this ->discard (E);
@@ -2283,7 +2283,7 @@ bool ByteCodeExprGen<Emitter>::visitInitializer(const Expr *E) {
2283
2283
assert (!classify (E->getType ()));
2284
2284
2285
2285
if (E->containsErrors ())
2286
- return false ;
2286
+ return this -> emitError (E) ;
2287
2287
2288
2288
OptionScope<Emitter> Scope (this , /* NewDiscardResult=*/ false ,
2289
2289
/* NewInitializing=*/ true );
Original file line number Diff line number Diff line change @@ -2227,6 +2227,9 @@ inline bool Invalid(InterpState &S, CodePtr OpPC) {
2227
2227
return false ;
2228
2228
}
2229
2229
2230
+ // / Do nothing and just abort execution.
2231
+ inline bool Error (InterpState &S, CodePtr OpPC) { return false ; }
2232
+
2230
2233
// / Same here, but only for casts.
2231
2234
inline bool InvalidCast (InterpState &S, CodePtr OpPC, CastKind Kind) {
2232
2235
const SourceLocation &Loc = S.Current ->getLocation (OpPC);
Original file line number Diff line number Diff line change @@ -706,6 +706,7 @@ def Dup : Opcode {
706
706
707
707
// [] -> []
708
708
def Invalid : Opcode {}
709
+ def Error : Opcode {}
709
710
def InvalidCast : Opcode {
710
711
let Args = [ArgCastKind];
711
712
}
Original file line number Diff line number Diff line change 1
- // RUN: %clang_cc1 -std=c++23 -fsyntax-only -fexperimental-new-constant-interpreter %s -verify
2
- // RUN: %clang_cc1 -std=c++23 -fsyntax-only %s -verify=ref
3
-
4
- // expected-no-diagnostics
5
- // ref-no-diagnostics
1
+ // RUN: %clang_cc1 -std=c++23 -fsyntax-only -fexperimental-new-constant-interpreter %s -verify=expected,both
2
+ // RUN: %clang_cc1 -std=c++23 -fsyntax-only %s -verify=ref,both
6
3
7
4
namespace ConstEval {
8
5
constexpr int f () {
@@ -51,3 +48,13 @@ namespace InitDecl {
51
48
}
52
49
static_assert (attrs() == 1 , " " );
53
50
};
51
+
52
+ // / The faulty if statement creates a RecoveryExpr with contains-errors,
53
+ // / but the execution will never reach that.
54
+ constexpr char g (char const (&x)[2]) {
55
+ return ' x' ;
56
+ if (auto [a, b] = x) // both-error {{an array type is not allowed here}} \
57
+ // both-warning {{ISO C++17 does not permit structured binding declaration in a condition}}
58
+ ;
59
+ }
60
+ static_assert (g(" x" ) == 'x');
You can’t perform that action at this time.
0 commit comments