summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-04-30 21:46:38 +0000
committerDouglas Gregor <dgregor@apple.com>2010-04-30 21:46:38 +0000
commitfabf95d0667b5dcc9da3d5537f1d3ca20b2914b5 (patch)
tree86f10c0aa1ddce026ebeea83e3e68cbc40cc19cb /clang/lib/Sema
parent4d4dcc8ed7441ceda5b975e7a1a0ead0a2ab86b2 (diff)
downloadbcm5719-llvm-fabf95d0667b5dcc9da3d5537f1d3ca20b2914b5.tar.gz
bcm5719-llvm-fabf95d0667b5dcc9da3d5537f1d3ca20b2914b5.zip
After substituting a template argument for a non-type template
parameter with pointer-to-member type, we may have to perform a qualification conversion, since the pointee type of the parameter might be more qualified than the pointee type of the argument we form from the declaration. Fixes PR6986. llvm-svn: 102777
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaTemplate.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index db9ed7e1efc..56410a2cfa4 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -3061,9 +3061,21 @@ Sema::BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg,
return ExprError();
RefExpr = CreateBuiltinUnaryOp(Loc, UnaryOperator::AddrOf, move(RefExpr));
+
+ // We might need to perform a trailing qualification conversion, since
+ // the element type on the parameter could be more qualified than the
+ // element type in the expression we constructed.
+ if (IsQualificationConversion(((Expr*) RefExpr.get())->getType(),
+ ParamType.getUnqualifiedType())) {
+ Expr *RefE = RefExpr.takeAs<Expr>();
+ ImpCastExprToType(RefE, ParamType.getUnqualifiedType(),
+ CastExpr::CK_NoOp);
+ RefExpr = Owned(RefE);
+ }
+
assert(!RefExpr.isInvalid() &&
Context.hasSameType(((Expr*) RefExpr.get())->getType(),
- ParamType));
+ ParamType.getUnqualifiedType()));
return move(RefExpr);
}
}
OpenPOWER on IntegriCloud