File tree Expand file tree Collapse file tree 2 files changed +48
-6
lines changed Expand file tree Collapse file tree 2 files changed +48
-6
lines changed Original file line number Diff line number Diff line change @@ -4974,20 +4974,35 @@ template <class Emitter> bool Compiler<Emitter>::visitIfStmt(const IfStmt *IS) {
4974
4974
LabelTy LabelEnd = this ->getLabel ();
4975
4975
if (!this ->jumpFalse (LabelElse))
4976
4976
return false ;
4977
- if (!visitStmt (IS->getThen ()))
4978
- return false ;
4977
+ {
4978
+ LocalScope<Emitter> ThenScope (this );
4979
+ if (!visitStmt (IS->getThen ()))
4980
+ return false ;
4981
+ if (!ThenScope.destroyLocals ())
4982
+ return false ;
4983
+ }
4979
4984
if (!this ->jump (LabelEnd))
4980
4985
return false ;
4981
4986
this ->emitLabel (LabelElse);
4982
- if (!visitStmt (Else))
4983
- return false ;
4987
+ {
4988
+ LocalScope<Emitter> ElseScope (this );
4989
+ if (!visitStmt (Else))
4990
+ return false ;
4991
+ if (!ElseScope.destroyLocals ())
4992
+ return false ;
4993
+ }
4984
4994
this ->emitLabel (LabelEnd);
4985
4995
} else {
4986
4996
LabelTy LabelEnd = this ->getLabel ();
4987
4997
if (!this ->jumpFalse (LabelEnd))
4988
4998
return false ;
4989
- if (!visitStmt (IS->getThen ()))
4990
- return false ;
4999
+ {
5000
+ LocalScope<Emitter> ThenScope (this );
5001
+ if (!visitStmt (IS->getThen ()))
5002
+ return false ;
5003
+ if (!ThenScope.destroyLocals ())
5004
+ return false ;
5005
+ }
4991
5006
this ->emitLabel (LabelEnd);
4992
5007
}
4993
5008
Original file line number Diff line number Diff line change @@ -76,3 +76,30 @@ namespace IfScope {
76
76
}
77
77
static_assert (foo() == 13 , " " );
78
78
}
79
+
80
+ namespace IfScope2 {
81
+ struct __bit_iterator {
82
+ unsigned __ctz_;
83
+ };
84
+ constexpr void __fill_n_bool (__bit_iterator) {}
85
+
86
+ constexpr void fill_n (__bit_iterator __first) {
87
+ if (false )
88
+ __fill_n_bool (__first);
89
+ else
90
+ __fill_n_bool (__first);
91
+ }
92
+
93
+ struct bitset {
94
+ constexpr void reset () {
95
+ auto m = __bit_iterator (8 );
96
+ fill_n (m);
97
+ }
98
+ };
99
+ consteval bool foo () {
100
+ bitset v;
101
+ v.reset ();
102
+ return true ;
103
+ }
104
+ static_assert (foo());
105
+ }
You can’t perform that action at this time.
0 commit comments