Decltype needs to have a dependent type if the expr passed to it is type dependent. Fixes PR4444.

llvm-svn: 74175
This commit is contained in:
Anders Carlsson 2009-06-25 15:00:34 +00:00
parent 1a20d2ab98
commit 7d209570b6
2 changed files with 9 additions and 0 deletions

View File

@ -1666,6 +1666,9 @@ QualType ASTContext::getTypeOfType(QualType tofType) {
/// getDecltypeForExpr - Given an expr, will return the decltype for that
/// expression, according to the rules in C++0x [dcl.type.simple]p4
static QualType getDecltypeForExpr(const Expr *e, ASTContext &Context) {
if (e->isTypeDependent())
return Context.DependentTy;
// If e is an id expression or a class member access, decltype(e) is defined
// as the type of the entity named by e.
if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(e)) {

View File

@ -0,0 +1,6 @@
// RUN: clang-cc -fsyntax-only -verify %s -std=c++0x
template<typename T, T t>
struct TestStruct {
typedef decltype(t+2) sum_type;
};