[cfe-commits] r124344 - in /cfe/trunk: lib/Sema/SemaType.cpp test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6-0x.cpp
Douglas Gregor
dgregor at apple.com
Wed Jan 26 17:30:16 PST 2011
Author: dgregor
Date: Wed Jan 26 19:30:16 2011
New Revision: 124344
URL: http://llvm.org/viewvc/llvm-project?rev=124344&view=rev
Log:
Cope with parenthesized function declarators when emitting a
diagnostic about ref-qualifiers where they do not belong.
Modified:
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6-0x.cpp
Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=124344&r1=124343&r2=124344&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Wed Jan 26 19:30:16 2011
@@ -1901,8 +1901,16 @@
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);
Modified: cfe/trunk/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6-0x.cpp?rev=124344&r1=124343&r2=124344&view=diff
==============================================================================
--- cfe/trunk/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6-0x.cpp (original)
+++ cfe/trunk/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6-0x.cpp Wed Jan 26 19:30:16 2011
@@ -24,3 +24,5 @@
void (X::*mpf1)() & = &X::f0;
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}}
More information about the cfe-commits
mailing list