diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-01-15 06:24:57 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-01-15 06:24:57 +0000 |
commit | fa16125aaf667c2bd80efcea403a7a71aa65da14 (patch) | |
tree | 34bd0c590d28b7748ffe84b5673061c76182a56c | |
parent | 244ee7b89a483fd3764637abdf95de2893b437d0 (diff) |
decltype(e) is type-dependent if e is instantiation-dependent. Scary but true.
Don't consider decltype(e) for an instantiation-dependent, but not
type-dependent, e to be non-type-dependent but canonical(!).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148210 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/AST/Type.cpp | 5 | ||||
-rw-r--r-- | test/SemaCXX/decltype.cpp | 9 |
2 files changed, 12 insertions, 2 deletions
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index 99468b8f61..7fd83b54e4 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -1739,7 +1739,10 @@ void DependentTypeOfExprType::Profile(llvm::FoldingSetNodeID &ID, } DecltypeType::DecltypeType(Expr *E, QualType underlyingType, QualType can) - : Type(Decltype, can, E->isTypeDependent(), + // C++11 [temp.type]p2: "If an expression e involves a template parameter, + // decltype(e) denotes a unique dependent type." Hence a decltype type is + // type-dependent even if its expression is only instantiation-dependent. + : Type(Decltype, can, E->isInstantiationDependent(), E->isInstantiationDependent(), E->getType()->isVariablyModifiedType(), E->containsUnexpandedParameterPack()), diff --git a/test/SemaCXX/decltype.cpp b/test/SemaCXX/decltype.cpp index 78fb8ef020..a1200e0820 100644 --- a/test/SemaCXX/decltype.cpp +++ b/test/SemaCXX/decltype.cpp @@ -20,4 +20,11 @@ namespace pr10154 { class A{ A(decltype(nullptr) param); }; -}
\ No newline at end of file +} + +template<typename T> struct S {}; +template<typename T> auto f(T t) -> decltype(S<int>(t)) { + using U = decltype(S<int>(t)); + using U = S<int>; + return S<int>(t); +} |