diff options
author | Anders Carlsson <andersca@mac.com> | 2009-06-25 15:00:34 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-06-25 15:00:34 +0000 |
commit | a07c33e64e1169e4261f7748c7f9191091a3ad2e (patch) | |
tree | 5b16ab1c3b77d16900b0a10c4867f12996ee62e3 | |
parent | 6887e63ff533d46046c47a2f0ea8765914fbfb76 (diff) |
Decltype needs to have a dependent type if the expr passed to it is type dependent. Fixes PR4444.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74175 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/AST/ASTContext.cpp | 3 | ||||
-rw-r--r-- | test/SemaCXX/decltype-pr4444.cpp | 6 |
2 files changed, 9 insertions, 0 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 377d2fbe9a..16a62fdd8c 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -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)) { diff --git a/test/SemaCXX/decltype-pr4444.cpp b/test/SemaCXX/decltype-pr4444.cpp new file mode 100644 index 0000000000..8b2f584d24 --- /dev/null +++ b/test/SemaCXX/decltype-pr4444.cpp @@ -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; +}; |