On Sat, Jan 14, 2012 at 10:50 PM, Eli Friedman <[email protected]> wrote: > On Sat, Jan 14, 2012 at 10:24 PM, Richard Smith > <[email protected]> wrote: >> Author: rsmith >> Date: Sun Jan 15 00:24:57 2012 >> New Revision: 148210 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=148210&view=rev >> Log: >> 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(!). >> >> Modified: >> cfe/trunk/lib/AST/Type.cpp >> cfe/trunk/test/SemaCXX/decltype.cpp >> >> Modified: cfe/trunk/lib/AST/Type.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=148210&r1=148209&r2=148210&view=diff >> ============================================================================== >> --- cfe/trunk/lib/AST/Type.cpp (original) >> +++ cfe/trunk/lib/AST/Type.cpp Sun Jan 15 00:24:57 2012 >> @@ -1739,7 +1739,10 @@ >> } >> >> 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()), >> >> Modified: cfe/trunk/test/SemaCXX/decltype.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/decltype.cpp?rev=148210&r1=148209&r2=148210&view=diff >> ============================================================================== >> --- cfe/trunk/test/SemaCXX/decltype.cpp (original) >> +++ cfe/trunk/test/SemaCXX/decltype.cpp Sun Jan 15 00:24:57 2012 >> @@ -20,4 +20,11 @@ >> 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); >> +} > > This testcase isn't valid C++ as far as I can tell; what are you > trying to show with it?
Err, wait, nevermind, it is; not sure what I was thinking. GIven that decltype(S<int>(t)) is always S<int>, no matter what t is, I'm not sure why we can't analyze this correctly without marking it dependent, though. -Eli _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
