diff options
author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2010-07-09 21:26:08 +0000 |
---|---|---|
committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2010-07-09 21:26:08 +0000 |
commit | c61bb2056148891375bfa591fa2859b9b6ec2734 (patch) | |
tree | 887068b2772f246ab05bd9f33ac2452de06ce5e5 /lib/Sema/SemaType.cpp | |
parent | ecf966e837097fb2ea0a80391e129bed7361d396 (diff) |
Slightly improve the diagnostic when using a qualified function typedef to declare nonmember or static member functions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108018 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaType.cpp')
-rw-r--r-- | lib/Sema/SemaType.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 244f218860..48bf7cbac4 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -1320,18 +1320,19 @@ TypeSourceInfo *Sema::GetTypeForDeclarator(Declarator &D, Scope *S, // for a nonstatic member function, the function type to which a pointer // to member refers, or the top-level function type of a function typedef // declaration. + bool FreeFunction = (D.getContext() != Declarator::MemberContext && + (!D.getCXXScopeSpec().isSet() || + !computeDeclContext(D.getCXXScopeSpec(), /*FIXME:*/true)->isRecord())); if (FnTy->getTypeQuals() != 0 && D.getDeclSpec().getStorageClassSpec() != DeclSpec::SCS_typedef && - ((D.getContext() != Declarator::MemberContext && - (!D.getCXXScopeSpec().isSet() || - !computeDeclContext(D.getCXXScopeSpec(), /*FIXME:*/true) - ->isRecord())) || + (FreeFunction || D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_static)) { if (D.isFunctionDeclarator()) Diag(D.getIdentifierLoc(), diag::err_invalid_qualified_function_type); else Diag(D.getIdentifierLoc(), - diag::err_invalid_qualified_typedef_function_type_use); + diag::err_invalid_qualified_typedef_function_type_use) + << FreeFunction; // Strip the cv-quals from the type. T = Context.getFunctionType(FnTy->getResultType(), FnTy->arg_type_begin(), |