forked from OSchip/llvm-project
Fix crash in typo correction while correcting enum within a struct in C
llvm-svn: 225513
This commit is contained in:
parent
0a092763e7
commit
ed13fab4bc
|
@ -5991,8 +5991,10 @@ static ExprResult attemptRecovery(Sema &SemaRef,
|
|||
if (auto *NNS = TC.getCorrectionSpecifier())
|
||||
Record = NNS->getAsType()->getAsCXXRecordDecl();
|
||||
if (!Record)
|
||||
Record = cast<CXXRecordDecl>(ND->getDeclContext()->getRedeclContext());
|
||||
R.setNamingClass(Record);
|
||||
Record =
|
||||
dyn_cast<CXXRecordDecl>(ND->getDeclContext()->getRedeclContext());
|
||||
if (Record)
|
||||
R.setNamingClass(Record);
|
||||
|
||||
// Detect and handle the case where the decl might be an implicit
|
||||
// member.
|
||||
|
|
|
@ -12,3 +12,14 @@ void PR21656() {
|
|||
|
||||
a = b ? : 0; // expected-warning {{type specifier missing, defaults to 'int'}} \
|
||||
// expected-error {{use of undeclared identifier 'b'}}
|
||||
|
||||
struct ContainerStuct {
|
||||
enum { SOME_ENUM }; // expected-note {{'SOME_ENUM' declared here}}
|
||||
};
|
||||
|
||||
void func(int arg) {
|
||||
switch (arg) {
|
||||
case SOME_ENUM_:
|
||||
; // expected-error {{use of undeclared identifier 'SOME_ENUM_'; did you mean 'SOME_ENUM'}}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue