diff options
Diffstat (limited to 'lib/Sema')
-rw-r--r-- | lib/Sema/SemaType.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 64d5c428f3..9e1d067fda 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -1901,8 +1901,16 @@ TypeSourceInfo *Sema::GetTypeForDeclarator(Declarator &D, Scope *S, if (FnTy->getRefQualifier()) { if (D.isFunctionDeclarator()) { - SourceLocation Loc - = D.getTypeObject(D.getNumTypeObjects()-1).Fun.getRefQualifierLoc(); + SourceLocation Loc = D.getIdentifierLoc(); + 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) << (FnTy->getRefQualifier() == RQ_LValue) << FixItHint::CreateRemoval(Loc); |