File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -6057,13 +6057,15 @@ bool Compiler<Emitter>::visitSwitchStmt(const SwitchStmt *S) {
60576057 DefaultLabel);
60586058 if (!this ->visitStmt (S->getBody ()))
60596059 return false ;
6060+ this ->fallthrough (EndLabel);
60606061 this ->emitLabel (EndLabel);
60616062
60626063 return LS.destroyLocals ();
60636064}
60646065
60656066template <class Emitter >
60666067bool Compiler<Emitter>::visitCaseStmt(const CaseStmt *S) {
6068+ this ->fallthrough (CaseLabels[S]);
60676069 this ->emitLabel (CaseLabels[S]);
60686070 return this ->visitStmt (S->getSubStmt ());
60696071}
Original file line number Diff line number Diff line change @@ -1270,6 +1270,17 @@ namespace StmtExprs {
12701270 namespace CrossFuncLabelDiff {
12711271 constexpr long a (bool x) { return x ? 0 : (intptr_t )&&lbl + (0 && ({lbl: 0 ;})); }
12721272 }
1273+
1274+ // / GCC agrees with the bytecode interpreter here.
1275+ void switchInSE () {
1276+ static_assert (({ // ref-error {{not an integral constant expression}}
1277+ int i = 20 ;
1278+ switch (10 ) {
1279+ case 10 : i = 300 ; // ref-note {{a constant expression cannot modify an object that is visible outside that expression}}
1280+ }
1281+ i;
1282+ }) == 300 );
1283+ }
12731284}
12741285#endif
12751286
You can’t perform that action at this time.
0 commit comments