[cfe-commits] r148210 - in /cfe/trunk: lib/AST/Type.cpp test/SemaCXX/decltype.cpp
Eli Friedman
eli.friedman at gmail.com
Sat Jan 14 22:50:16 PST 2012
On Sat, Jan 14, 2012 at 10:24 PM, Richard Smith
<richard-llvm at metafoo.co.uk> 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?
-Eli
More information about the cfe-commits
mailing list