Fix PR4448.

llvm-svn: 74257
This commit is contained in:
Anders Carlsson 2009-06-26 03:02:18 +00:00
parent b44c26b7aa
commit 5140b3c4a6
4 changed files with 21 additions and 2 deletions

View File

@ -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:

View File

@ -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);

View File

@ -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())

View File

@ -0,0 +1,8 @@
// RUN: clang-cc -fsyntax-only -verify %s -std=c++0x
template< typename T, T t, decltype(t+2) v >
struct Convoluted {};
int test_array[5];
Convoluted< int *, test_array, nullptr > tarray;