diff options
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r-- | clang/lib/Sema/SemaTemplateInstantiate.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp index 2db0deb5098..3efb52e91bf 100644 --- a/clang/lib/Sema/SemaTemplateInstantiate.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -746,6 +746,22 @@ TemplateInstantiator::TransformDeclRefExpr(DeclRefExpr *E) { move(RefExpr)); } } + if (NTTP->getType()->isPointerType() && + !VD->getType()->isPointerType()) { + // If the template argument is expected to be a pointer and value + // isn't inherently of pointer type, then it is specified with '&...' + // to indicate its address should be used. Build an expression to + // take the address of the argument. + OwningExprResult RefExpr + = SemaRef.BuildDeclRefExpr(VD, VD->getType().getNonReferenceType(), + E->getLocation()); + if (RefExpr.isInvalid()) + return SemaRef.ExprError(); + + return SemaRef.CreateBuiltinUnaryOp(E->getLocation(), + UnaryOperator::AddrOf, + move(RefExpr)); + } return SemaRef.BuildDeclRefExpr(VD, VD->getType().getNonReferenceType(), E->getLocation()); |