|
@@ -140,7 +140,8 @@ TemplateNameKind Sema::isTemplateName(Scope *S,
|
|
ParsedType ObjectTypePtr,
|
|
ParsedType ObjectTypePtr,
|
|
bool EnteringContext,
|
|
bool EnteringContext,
|
|
TemplateTy &TemplateResult,
|
|
TemplateTy &TemplateResult,
|
|
- bool &MemberOfUnknownSpecialization) {
|
|
|
|
|
|
+ bool &MemberOfUnknownSpecialization,
|
|
|
|
+ bool NextIsLess) { // HLSL CHange
|
|
assert(getLangOpts().CPlusPlus && "No template names in C!");
|
|
assert(getLangOpts().CPlusPlus && "No template names in C!");
|
|
|
|
|
|
DeclarationName TName;
|
|
DeclarationName TName;
|
|
@@ -168,7 +169,8 @@ TemplateNameKind Sema::isTemplateName(Scope *S,
|
|
|
|
|
|
LookupResult R(*this, TName, Name.getLocStart(), LookupOrdinaryName);
|
|
LookupResult R(*this, TName, Name.getLocStart(), LookupOrdinaryName);
|
|
LookupTemplateName(R, S, SS, ObjectType, EnteringContext,
|
|
LookupTemplateName(R, S, SS, ObjectType, EnteringContext,
|
|
- MemberOfUnknownSpecialization);
|
|
|
|
|
|
+ MemberOfUnknownSpecialization,
|
|
|
|
+ NextIsLess); // HLSL Change
|
|
if (R.empty()) return TNK_Non_template;
|
|
if (R.empty()) return TNK_Non_template;
|
|
if (R.isAmbiguous()) {
|
|
if (R.isAmbiguous()) {
|
|
// Suppress diagnostics; we'll redo this lookup later.
|
|
// Suppress diagnostics; we'll redo this lookup later.
|
|
@@ -248,7 +250,8 @@ void Sema::LookupTemplateName(LookupResult &Found,
|
|
Scope *S, CXXScopeSpec &SS,
|
|
Scope *S, CXXScopeSpec &SS,
|
|
QualType ObjectType,
|
|
QualType ObjectType,
|
|
bool EnteringContext,
|
|
bool EnteringContext,
|
|
- bool &MemberOfUnknownSpecialization) {
|
|
|
|
|
|
+ bool &MemberOfUnknownSpecialization,
|
|
|
|
+ bool NextIsLess) { // HLSL Change
|
|
// Determine where to perform name lookup
|
|
// Determine where to perform name lookup
|
|
MemberOfUnknownSpecialization = false;
|
|
MemberOfUnknownSpecialization = false;
|
|
DeclContext *LookupCtx = nullptr;
|
|
DeclContext *LookupCtx = nullptr;
|
|
@@ -319,9 +322,8 @@ void Sema::LookupTemplateName(LookupResult &Found,
|
|
|
|
|
|
// HLSL Change: do not try to save template name lookups with auto-correct,
|
|
// HLSL Change: do not try to save template name lookups with auto-correct,
|
|
// otherwise identifiers like variable-names might match and fail;
|
|
// otherwise identifiers like variable-names might match and fail;
|
|
- // ideally we would still do this if 'nextIsLess' was known to be true,
|
|
|
|
- // but this is a more localized change.
|
|
|
|
- if (Found.empty() && !isDependent && !getLangOpts().HLSL) {
|
|
|
|
|
|
+ // however we still do this if 'NextIsLess' is known to be true.
|
|
|
|
+ if (Found.empty() && !isDependent && (!getLangOpts().HLSL || NextIsLess)) {
|
|
// If we did not find any names, attempt to correct any typos.
|
|
// If we did not find any names, attempt to correct any typos.
|
|
DeclarationName Name = Found.getLookupName();
|
|
DeclarationName Name = Found.getLookupName();
|
|
Found.clear();
|
|
Found.clear();
|
|
@@ -3056,15 +3058,20 @@ bool Sema::CheckTemplateTypeArgument(TemplateTypeParmDecl *Param,
|
|
case TemplateArgument::Template: {
|
|
case TemplateArgument::Template: {
|
|
// We have a template type parameter but the template argument
|
|
// We have a template type parameter but the template argument
|
|
// is a template without any arguments.
|
|
// is a template without any arguments.
|
|
|
|
+ // HLSL Change Starts
|
|
|
|
+ // We suppress some errors when templates are enabled in order to preserve
|
|
|
|
+ // backwards compatibility.
|
|
SourceRange SR = AL.getSourceRange();
|
|
SourceRange SR = AL.getSourceRange();
|
|
TemplateName Name = Arg.getAsTemplate();
|
|
TemplateName Name = Arg.getAsTemplate();
|
|
|
|
+ TemplateDecl *Decl = Name.getAsTemplateDecl();
|
|
|
|
+ if (Decl && !Decl->getLocation().isValid() && getLangOpts().EnableTemplates)
|
|
|
|
+ break;
|
|
Diag(SR.getBegin(), diag::err_template_missing_args)
|
|
Diag(SR.getBegin(), diag::err_template_missing_args)
|
|
<< Name << SR;
|
|
<< Name << SR;
|
|
- if (TemplateDecl *Decl = Name.getAsTemplateDecl()) {
|
|
|
|
- if (Decl->getLocation().isValid()) { // HLSL Change - ellide location notes for built-ins
|
|
|
|
|
|
+ if (Decl && Decl->getLocation().isValid()) { // HLSL Change - ellide location notes for built-ins
|
|
Diag(Decl->getLocation(), diag::note_template_decl_here);
|
|
Diag(Decl->getLocation(), diag::note_template_decl_here);
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
+ // HLSL Change Ends
|
|
|
|
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|