forked from OSchip/llvm-project
Cope with parenthesized function declarators when emitting a
diagnostic about ref-qualifiers where they do not belong. llvm-svn: 124344
This commit is contained in:
parent
9864b5ec5f
commit
dff0be70ba
|
@ -1901,8 +1901,16 @@ TypeSourceInfo *Sema::GetTypeForDeclarator(Declarator &D, Scope *S,
|
||||||
|
|
||||||
if (FnTy->getRefQualifier()) {
|
if (FnTy->getRefQualifier()) {
|
||||||
if (D.isFunctionDeclarator()) {
|
if (D.isFunctionDeclarator()) {
|
||||||
SourceLocation Loc
|
SourceLocation Loc = D.getIdentifierLoc();
|
||||||
= D.getTypeObject(D.getNumTypeObjects()-1).Fun.getRefQualifierLoc();
|
for (unsigned I = 0, N = D.getNumTypeObjects(); I != N; ++I) {
|
||||||
|
const DeclaratorChunk &Chunk = D.getTypeObject(N-I-1);
|
||||||
|
if (Chunk.Kind == DeclaratorChunk::Function &&
|
||||||
|
Chunk.Fun.hasRefQualifier()) {
|
||||||
|
Loc = Chunk.Fun.getRefQualifierLoc();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Diag(Loc, diag::err_invalid_ref_qualifier_function_type)
|
Diag(Loc, diag::err_invalid_ref_qualifier_function_type)
|
||||||
<< (FnTy->getRefQualifier() == RQ_LValue)
|
<< (FnTy->getRefQualifier() == RQ_LValue)
|
||||||
<< FixItHint::CreateRemoval(Loc);
|
<< FixItHint::CreateRemoval(Loc);
|
||||||
|
|
|
@ -24,3 +24,5 @@ struct Y {
|
||||||
void (X::*mpf1)() & = &X::f0;
|
void (X::*mpf1)() & = &X::f0;
|
||||||
void (X::*mpf2)() && = &X::f1;
|
void (X::*mpf2)() && = &X::f1;
|
||||||
|
|
||||||
|
|
||||||
|
void (f() &&); // expected-error{{ref-qualifier '&&' is only allowed on non-static member functions, member function pointers, and typedefs of function types}}
|
||||||
|
|
Loading…
Reference in New Issue