C++ warning PATCH
Mark Mitchell
mark@markmitchell.com
Thu Oct 15 12:19:00 GMT 1998
This patch improves warning messages on code like:
class C {
private:
C();
C(const C&);
};
We used to say that all member functions are private; we now say that
all constructors are private, as the code originally intendned.
--
Mark Mitchell mark@markmitchell.com
Mark Mitchell Consulting http://www.markmitchell.com
1998-10-15 Mark Mitchell <mark@markmitchell.com>
* class.c (maybe_warn_about_overly_private_class): Improve error
messages for class with only private constructors.
Index: class.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/class.c,v
retrieving revision 1.91
diff -c -p -r1.91 class.c
*** class.c 1998/10/07 09:30:50 1.91
--- class.c 1998/10/15 18:33:43
*************** maybe_warn_about_overly_private_class (t
*** 2013,2024 ****
has_nonprivate_method = 1;
break;
}
! else
has_member_fn = 1;
}
if (!has_nonprivate_method && has_member_fn)
{
int i;
tree binfos = BINFO_BASETYPES (TYPE_BINFO (t));
for (i = 0; i < CLASSTYPE_N_BASECLASSES (t); i++)
--- 2013,2030 ----
has_nonprivate_method = 1;
break;
}
! else if (!DECL_CONSTRUCTOR_P (fn) && !DECL_DESTRUCTOR_P (fn))
has_member_fn = 1;
}
if (!has_nonprivate_method && has_member_fn)
{
+ /* There are no non-private methods, and there's at least one
+ private member function that isn't a constructor or
+ destructor. (If all the private members are
+ constructors/destructors we want to use the code below that
+ issues error messages specifically referring to
+ constructors/destructors.) */
int i;
tree binfos = BINFO_BASETYPES (TYPE_BINFO (t));
for (i = 0; i < CLASSTYPE_N_BASECLASSES (t); i++)
More information about the Gcc-patches
mailing list