diff options
author | Patrick Palka <ppalka@redhat.com> | 2022-04-26 10:53:38 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2022-04-26 10:53:38 -0400 |
commit | b6a48401da51e9042b6f0822d532b3b472492658 (patch) | |
tree | b0d11ef6a5a9a2834c9782b44402ad96f07af3a9 | |
parent | cd4acb8cd9e45fd35664baa5b0a3150e479aae32 (diff) | |
download | gcc-b6a48401da51e9042b6f0822d532b3b472492658.zip gcc-b6a48401da51e9042b6f0822d532b3b472492658.tar.gz gcc-b6a48401da51e9042b6f0822d532b3b472492658.tar.bz2 |
c++: decltype of non-dependent call of class type [PR105386]
We need to pass tf_decltype when instantiating a non-dependent decltype
operand, like tsubst does in the dependent case, so that we don't force
completion of a prvalue operand's class type.
PR c++/105386
gcc/cp/ChangeLog:
* semantics.cc (finish_decltype_type): Pass tf_decltype to
instantiate_non_dependent_expr_sfinae.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/decltype81.C: New test.
-rw-r--r-- | gcc/cp/semantics.cc | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/decltype81.C | 15 |
2 files changed, 16 insertions, 1 deletions
diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index f08c0b6..ab48f11 100644 --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -11252,7 +11252,7 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p, } else if (processing_template_decl) { - expr = instantiate_non_dependent_expr_sfinae (expr, complain); + expr = instantiate_non_dependent_expr_sfinae (expr, complain|tf_decltype); if (expr == error_mark_node) return error_mark_node; /* Keep processing_template_decl cleared for the rest of the function diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype81.C b/gcc/testsuite/g++.dg/cpp0x/decltype81.C new file mode 100644 index 0000000..7d25db3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype81.C @@ -0,0 +1,15 @@ +// PR c++/105386 +// { dg-do compile { target c++11 } } + +template<class T> struct NoInst { + static_assert(sizeof(T) == 9999, "NoInst instantiated"); +}; + +template<class T> NoInst<T> f(T); + +template<class> +struct A { + using type = decltype(f(0)); +}; + +A<int> a; |