diff options
author | Anders Carlsson <andersca@mac.com> | 2009-06-26 03:02:18 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-06-26 03:02:18 +0000 |
commit | 87471f5b64783c52e01e7accc1b123560b52bf35 (patch) | |
tree | 04f070d083a53eadced8eff9521f0bef75084e59 /lib | |
parent | 58d29a41271d96509f464716f79b0ab2e815b6b1 (diff) |
Fix PR4448.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74257 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Parse/ParseDeclCXX.cpp | 2 | ||||
-rw-r--r-- | lib/Sema/SemaTemplateInstantiate.cpp | 5 | ||||
-rw-r--r-- | lib/Sema/SemaTemplateInstantiateExpr.cpp | 8 |
3 files changed, 13 insertions, 2 deletions
diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index 188580de20..fed03a8c34 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -365,14 +365,12 @@ void Parser::ParseDecltypeSpecifier(DeclSpec &DS) { SourceLocation StartLoc = ConsumeToken(); SourceLocation LParenLoc = Tok.getLocation(); - if (ExpectAndConsume(tok::l_paren, diag::err_expected_lparen_after, "decltype")) { SkipUntil(tok::r_paren); return; } - // Parse the expression // C++0x [dcl.type.simple]p4: diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp index 5e4fde7af9..0c78c71206 100644 --- a/lib/Sema/SemaTemplateInstantiate.cpp +++ b/lib/Sema/SemaTemplateInstantiate.cpp @@ -560,6 +560,11 @@ TemplateTypeInstantiator::InstantiateTypeOfType(const TypeOfType *T, QualType TemplateTypeInstantiator::InstantiateDecltypeType(const DecltypeType *T, unsigned Quals) const { + // C++0x [dcl.type.simple]p4: + // The operand of the decltype specifier is an unevaluated operand. + EnterExpressionEvaluationContext Unevaluated(SemaRef, + Action::Unevaluated); + Sema::OwningExprResult E = SemaRef.InstantiateExpr(T->getUnderlyingExpr(), TemplateArgs); diff --git a/lib/Sema/SemaTemplateInstantiateExpr.cpp b/lib/Sema/SemaTemplateInstantiateExpr.cpp index aba2c99ef8..65a35f92f7 100644 --- a/lib/Sema/SemaTemplateInstantiateExpr.cpp +++ b/lib/Sema/SemaTemplateInstantiateExpr.cpp @@ -119,6 +119,14 @@ TemplateExprInstantiator::VisitDeclRefExpr(DeclRefExpr *E) { // FIXME: Clone the expression! return SemaRef.Owned(Arg.getAsExpr()); + if (Arg.getKind() == TemplateArgument::Declaration) { + ValueDecl *VD = cast<ValueDecl>(Arg.getAsDecl()); + + // FIXME: Can VD ever have a dependent type? + return SemaRef.BuildDeclRefExpr(VD, VD->getType(), E->getLocation(), + false, false); + } + assert(Arg.getKind() == TemplateArgument::Integral); QualType T = Arg.getIntegralType(); if (T->isCharType() || T->isWideCharType()) |