diff options
| author | Douglas Gregor <dgregor@apple.com> | 2009-07-22 20:02:25 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2009-07-22 20:02:25 +0000 |
| commit | 60454827929a764cb31fef5aa27c4c7d0a581e7e (patch) | |
| tree | db017bff773d7208f974a2bfb6edfbeaee6c1675 /clang/lib | |
| parent | af6ab88979408e723611d880cf14e975ab96248e (diff) | |
| download | bcm5719-llvm-60454827929a764cb31fef5aa27c4c7d0a581e7e.tar.gz bcm5719-llvm-60454827929a764cb31fef5aa27c4c7d0a581e7e.zip | |
Improve template argument deduction for array types, so that a parameter
const T
can be matched with, e.g.,
volatile int [5]
llvm-svn: 76773
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Sema/SemaTemplateDeduction.cpp | 8 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaTemplateInstantiate.cpp | 1 |
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()); |

