forked from OSchip/llvm-project
Fix crash w/BlockDecl and invalid qualified decl.
I'm not really satisfied with the ad-hoc nature of Sema::diagnoseQualifiedDeclaration, but I'm not sure how to fix it. Fixes <rdar://problem/14639501>. llvm-svn: 188208
This commit is contained in:
parent
48a317663f
commit
e2358c1deb
|
@ -5100,6 +5100,8 @@ def err_invalid_declarator_global_scope : Error<
|
|||
"definition or redeclaration of %0 cannot name the global scope">;
|
||||
def err_invalid_declarator_in_function : Error<
|
||||
"definition or redeclaration of %0 not allowed inside a function">;
|
||||
def err_invalid_declarator_in_block : Error<
|
||||
"definition or redeclaration of %0 not allowed inside a block">;
|
||||
def err_not_tag_in_scope : Error<
|
||||
"no %select{struct|interface|union|class|enum}0 named %1 in %2">;
|
||||
def err_not_var_in_scope : Error<
|
||||
|
|
|
@ -3998,7 +3998,7 @@ bool Sema::diagnoseQualifiedDeclaration(CXXScopeSpec &SS, DeclContext *DC,
|
|||
DeclarationName Name,
|
||||
SourceLocation Loc) {
|
||||
DeclContext *Cur = CurContext;
|
||||
while (isa<LinkageSpecDecl>(Cur))
|
||||
while (isa<LinkageSpecDecl>(Cur) || isa<CapturedDecl>(Cur))
|
||||
Cur = Cur->getParent();
|
||||
|
||||
// C++ [dcl.meaning]p1:
|
||||
|
@ -4036,6 +4036,9 @@ bool Sema::diagnoseQualifiedDeclaration(CXXScopeSpec &SS, DeclContext *DC,
|
|||
else if (isa<FunctionDecl>(Cur))
|
||||
Diag(Loc, diag::err_invalid_declarator_in_function)
|
||||
<< Name << SS.getRange();
|
||||
else if (isa<BlockDecl>(Cur))
|
||||
Diag(Loc, diag::err_invalid_declarator_in_block)
|
||||
<< Name << SS.getRange();
|
||||
else
|
||||
Diag(Loc, diag::err_invalid_declarator_scope)
|
||||
<< Name << cast<NamedDecl>(Cur) << cast<NamedDecl>(DC) << SS.getRange();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: %clang_cc1 -fsyntax-only -std=c++98 -verify %s
|
||||
// RUN: %clang_cc1 -fsyntax-only -std=c++98 -verify -fblocks %s
|
||||
namespace A {
|
||||
struct C {
|
||||
static int cx;
|
||||
|
@ -50,6 +50,7 @@ namespace B {
|
|||
|
||||
void f1() {
|
||||
void A::Af(); // expected-error {{definition or redeclaration of 'Af' not allowed inside a function}}
|
||||
void (^x)() = ^{ void A::Af(); }; // expected-error {{definition or redeclaration of 'Af' not allowed inside a block}}
|
||||
}
|
||||
|
||||
void f2() {
|
||||
|
|
Loading…
Reference in New Issue