зеркало из https://github.com/microsoft/clang.git
Improve parser recovery when a switch condition is invalid; fixes
<rdar://problem/7971948>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104291 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
72a43bbf68
Коммит
4186ff4fc4
|
@ -754,9 +754,10 @@ Parser::OwningStmtResult Parser::ParseSwitchStatement(AttributeList *Attr) {
|
|||
// FIXME: This is not optimal recovery, but parsing the body is more
|
||||
// dangerous due to the presence of case and default statements, which
|
||||
// will have no place to connect back with the switch.
|
||||
if (Tok.is(tok::l_brace))
|
||||
MatchRHSPunctuation(tok::r_brace, ConsumeBrace());
|
||||
else
|
||||
if (Tok.is(tok::l_brace)) {
|
||||
ConsumeBrace();
|
||||
SkipUntil(tok::r_brace, false, false);
|
||||
} else
|
||||
SkipUntil(tok::semi);
|
||||
return move(Switch);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
||||
|
||||
// <rdar://problem/7971948>
|
||||
struct A {};
|
||||
struct B {
|
||||
void foo() {
|
||||
switch (a) { // expected-error{{use of undeclared identifier 'a'}}
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
Загрузка…
Ссылка в новой задаче