diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index f08c0b6281fb..ab48f11c9be5 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 000000000000..7d25db39d9c7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype81.C @@ -0,0 +1,15 @@ +// PR c++/105386 +// { dg-do compile { target c++11 } } + +template struct NoInst { + static_assert(sizeof(T) == 9999, "NoInst instantiated"); +}; + +template NoInst f(T); + +template +struct A { + using type = decltype(f(0)); +}; + +A a;