2018-06-11 Jason Merrill <jason@redhat.com>
+ PR c++/85792 -Wctor-dtor-privacy and inherited constructor.
+ * class.c (maybe_warn_about_overly_private_class): Handle inherited
+ constructors.
+
PR c++/85963 - -Wunused-but-set with ?: in template.
* pt.c (tsubst_copy_and_build) [COND_EXPR]: Call mark_rvalue_use.
{
int has_member_fn = 0;
int has_nonprivate_method = 0;
+ bool nonprivate_ctor = false;
if (!warn_ctor_dtor_privacy
/* If the class has friends, those entities might create and
non-private statics, we can't ever call any of the private member
functions.) */
for (tree fn = TYPE_FIELDS (t); fn; fn = DECL_CHAIN (fn))
- if (!DECL_DECLARES_FUNCTION_P (fn))
+ if (TREE_CODE (fn) == USING_DECL
+ && DECL_NAME (fn) == ctor_identifier
+ && !TREE_PRIVATE (fn))
+ nonprivate_ctor = true;
+ else if (!DECL_DECLARES_FUNCTION_P (fn))
/* Not a function. */;
else if (DECL_ARTIFICIAL (fn))
/* We're not interested in compiler-generated methods; they don't
/* Implicitly generated constructors are always public. */
&& !CLASSTYPE_LAZY_DEFAULT_CTOR (t))
{
- bool nonprivate_ctor = false;
tree copy_or_move = NULL_TREE;
/* If a non-template class does not define a copy
--- /dev/null
+// PR c++/85792
+// { dg-do compile { target c++11 } }
+// { dg-additional-options -Wctor-dtor-privacy }
+
+template<typename T> struct A { };
+
+template<typename T> struct B : A<T> {
+ using A<T>::A;
+
+ B(const B&) { }
+};