Diagnose attempts to use 'using typename' with a non-identifier name,
from Stepan Dyatkovskiy. Fixes PR10925. llvm-svn: 140528
This commit is contained in:
parent
577372ea15
commit
882a61a640
|
@ -225,6 +225,9 @@ def err_typename_invalid_storageclass : Error<
|
|||
"type name does not allow storage class to be specified">;
|
||||
def err_typename_invalid_functionspec : Error<
|
||||
"type name does not allow function specifier to be specified">;
|
||||
def err_typename_identifiers_only : Error<
|
||||
"typename is allowed for identifiers only">;
|
||||
|
||||
def err_invalid_decl_spec_combination : Error<
|
||||
"cannot combine with previous '%0' declaration specifier">;
|
||||
def err_invalid_vector_decl_spec_combination : Error<
|
||||
|
|
|
@ -545,6 +545,15 @@ Decl *Parser::ParseUsingDeclaration(unsigned Context,
|
|||
return 0;
|
||||
}
|
||||
|
||||
// "typename" keyword is allowed for identifiers only,
|
||||
// because it may be a type definition.
|
||||
if (IsTypeName && Name.getKind() != UnqualifiedId::IK_Identifier) {
|
||||
Diag(Name.getSourceRange().getBegin(), diag::err_typename_identifiers_only)
|
||||
<< FixItHint::CreateRemoval(SourceRange(TypenameLoc));
|
||||
// Proceed parsing, but reset the IsTypeName flag.
|
||||
IsTypeName = false;
|
||||
}
|
||||
|
||||
if (IsAliasDecl) {
|
||||
TemplateParameterLists *TemplateParams = TemplateInfo.TemplateParams;
|
||||
MultiTemplateParamsArg TemplateParamsArg(Actions,
|
||||
|
|
|
@ -102,3 +102,16 @@ struct H {
|
|||
};
|
||||
|
||||
G<H> struct_G;
|
||||
|
||||
namespace PR10925 {
|
||||
template< int mydim, typename Traits >
|
||||
class BasicGeometry
|
||||
{
|
||||
typedef int some_type_t;
|
||||
};
|
||||
|
||||
template<class ctype, int mydim, int coorddim>
|
||||
class MockGeometry : BasicGeometry<mydim, int>{
|
||||
using typename BasicGeometry<mydim, int>::operator[]; // expected-error {{typename is allowed for identifiers only}}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue