+2020-02-05 Jason Merrill <jason@redhat.com>
+
+ PR c++/92593
+ * decl.c (grokdeclarator): Reject field of current class type even
+ in a template.
+
2020-02-05 Bin Cheng <bin.cheng@linux.alibaba.com>
* coroutines.cc (maybe_promote_captured_temps): Increase the index
if (declspecs->explicit_specifier)
store_explicit_specifier (decl, declspecs->explicit_specifier);
}
- else if (!staticp && !dependent_type_p (type)
- && !COMPLETE_TYPE_P (complete_type (type))
- && (!complete_or_array_type_p (type)
- || initialized == 0))
+ else if (!staticp
+ && ((current_class_type
+ && same_type_p (type, current_class_type))
+ || (!dependent_type_p (type)
+ && !COMPLETE_TYPE_P (complete_type (type))
+ && (!complete_or_array_type_p (type)
+ || initialized == 0))))
{
if (TREE_CODE (type) != ARRAY_TYPE
|| !COMPLETE_TYPE_P (TREE_TYPE (type)))
--- /dev/null
+// PR c++/92593
+// { dg-do compile { target c++17 } }
+
+template<int I>
+struct ref_view
+{
+ ref_view(T) { }; // { dg-error "incomplete" }
+};
+
+ref_view r{1}; // { dg-error "no match|deduction failed" }
// Origin: Volker Reichelt <reichelt@igpm.rwth-aachen.de>
// { dg-do compile }
-template<typename T> struct A { A(B); };
+template<typename T> struct A { A(B); }; // { dg-error "incomplete" }
template<typename T> A<T>::A(B) {} // { dg-error "" }
template < typename > struct A
{
- A a;
+ A a; // { dg-error "incomplete" }
template < int > using B = decltype (a);
- B < 0 > b;
+ B < 0 > b; // { dg-prune-output "B. does not name a type" }
template < int C > B < C > foo ();
};