diff options
| author | Chandler Carruth <chandlerc@gmail.com> | 2010-01-31 07:09:11 +0000 |
|---|---|---|
| committer | Chandler Carruth <chandlerc@gmail.com> | 2010-01-31 07:09:11 +0000 |
| commit | 9b1fa25432939fcb1ad6763dfca73a98c1eb230f (patch) | |
| tree | 5bc9dccf2c3a22a2c1b5ad590f0dab1c960d3096 /clang/lib | |
| parent | 7f62def0f9d019493cdcaf014dc4c4774f9fa01a (diff) | |
| download | bcm5719-llvm-9b1fa25432939fcb1ad6763dfca73a98c1eb230f.tar.gz bcm5719-llvm-9b1fa25432939fcb1ad6763dfca73a98c1eb230f.zip | |
Handle instantiation of templates with non-type arguments expressed with an
explicit '&' by introducing an address-of operator prior to checking the
argument's type.
llvm-svn: 94947
Diffstat (limited to 'clang/lib')
| -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()); |

