summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaTemplateDeduction.cpp8
-rw-r--r--clang/lib/Sema/SemaTemplateInstantiate.cpp1
2 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp
index ac4e4b9b28c..4e6d0f4dd16 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -341,6 +341,14 @@ DeduceTemplateArguments(ASTContext &Context,
= Param->getAsTemplateTypeParmType()) {
unsigned Index = TemplateTypeParm->getIndex();
+ // If the argument type is an array type, move the qualifiers up to the
+ // top level, so they can be matched with the qualifiers on the parameter.
+ // FIXME: address spaces, ObjC GC qualifiers
+ QualType ArgElementType = Arg;
+ while (const ArrayType *ArgArray = ArgElementType->getAs<ArrayType>())
+ ArgElementType = ArgArray->getElementType();
+ Arg = Arg.getWithAdditionalQualifiers(ArgElementType.getCVRQualifiers());
+
// The argument type can not be less qualified than the parameter
// type.
if (Param.isMoreQualifiedThan(Arg) && !(TDF & TDF_IgnoreQualifiers)) {
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index b58422b489c..a75a8584d1f 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -758,6 +758,7 @@ QualType TemplateTypeInstantiator::Instantiate(QualType T) const {
// which case the cv-qualifiers are ignored.
//
// The same rule applies to function types.
+ // FIXME: what about address-space and Objective-C GC qualifiers?
if (!Result.isNull() && T.getCVRQualifiers() &&
!Result->isFunctionType() && !Result->isReferenceType())
Result = Result.getWithAdditionalQualifiers(T.getCVRQualifiers());
OpenPOWER on IntegriCloud