File tree Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -161,6 +161,8 @@ Bug Fixes in This Version
161
161
targets that treat ``_Float16 ``/``__fp16 `` as native scalar types. Previously
162
162
the warning was silently lost because the operands differed only by an implicit
163
163
cast chain. (#GH149967).
164
+ - Correct the continue and break scope for while statements to be after the
165
+ condition is evaluated.
164
166
165
167
Bug Fixes to Compiler Builtins
166
168
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Original file line number Diff line number Diff line change @@ -1734,7 +1734,6 @@ StmtResult Parser::ParseWhileStatement(SourceLocation *TrailingElseLoc) {
1734
1734
Scope::DeclScope | Scope::ControlScope;
1735
1735
else
1736
1736
ScopeFlags = Scope::BreakScope | Scope::ContinueScope;
1737
- ParseScope WhileScope (this , ScopeFlags);
1738
1737
1739
1738
// Parse the condition.
1740
1739
Sema::ConditionResult Cond;
@@ -1744,6 +1743,8 @@ StmtResult Parser::ParseWhileStatement(SourceLocation *TrailingElseLoc) {
1744
1743
Sema::ConditionKind::Boolean, LParen, RParen))
1745
1744
return StmtError ();
1746
1745
1746
+ ParseScope WhileScope (this , ScopeFlags);
1747
+
1747
1748
// OpenACC Restricts a while-loop inside of certain construct/clause
1748
1749
// combinations, so diagnose that here in OpenACC mode.
1749
1750
SemaOpenACC::LoopInConstructRAII LCR{getActions ().OpenACC ()};
Original file line number Diff line number Diff line change
1
+ // RUN: %clang_cc1 -fsyntax-only -verify %s
2
+
3
+ void f () {
4
+ while (({ continue ; 1 ; })) {
5
+ // expected-error@-1 {{'continue' statement not in loop statement}}
6
+
7
+ }
8
+ while (({ break ; 1 ; })) {
9
+ // expected-error@-1 {{'break' statement not in loop or switch statement}}
10
+ }
11
+ }
You can’t perform that action at this time.
0 commit comments