[cfe-commits] r81233 - in /cfe/trunk: include/clang/Parse/Action.h lib/Parse/ParseDeclCXX.cpp lib/Sema/Sema.h lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaTemplate.cpp test/CXX/temp/temp.decls/temp.friend/p1.cpp
Douglas Gregor
dgregor at apple.com
Tue Sep 8 16:54:02 PDT 2009
On Sep 8, 2009, at 10:47 AM, John McCall wrote:
> Author: rjmccall
> Date: Tue Sep 8 12:47:29 2009
> New Revision: 81233
>
> URL: http://llvm.org/viewvc/llvm-project?rev=81233&view=rev
> Log:
> Support templateids in friend declarations. Fixes bug 4859.
Nifty.
> + // The parser doesn't quite handle
> + // friend class A { ... }
> + // optimally, because it might have been the (valid) prefix of
> + // friend class A { ... } foo();
> + // So in a very particular set of circumstances, we need to adjust
> + // IsDefinition.
"friend class A { ... } foo();" is ill-formed, since types cannot be
defined in a return type (C++ [dcl.fct]p6).
Is this mainly an issue of recovery?
> +
> + if (const RecordType *RT = Type->getAs<RecordType>()) {
> + RecordDecl *D = RT->getDecl();
> +
> + IdentifierInfo *Id = D->getIdentifier();
> + assert(Id && "templated class must have an identifier");
> +
> + if (!isAcceptableTagRedeclaration(D, TagKind, TagLoc, *Id)) {
> + Diag(TagLoc, diag::err_use_with_wrong_tag)
> + << Id
> + << CodeModificationHint::CreateReplacement(SourceRange
> (TagLoc),
> + D->getKindName());
Very nice fix-it hint.
- Doug
More information about the cfe-commits
mailing list