Commit 74fa0285 by Gabriel Dos Reis Committed by Gabriel Dos Reis

class.c (check_bases): Likewise.

        * class.c (check_bases): Likewise.
        (maybe_warn_about_overly_private_class): Likewise.
        (check_field_decls): Likewise.
        (layout_empty_base): Likewise.
        (layout_virtual_bases): Likewise.
        (layout_class_type): Likewise.

        * call.c (joust): Pass option code to warning.  Use inform for
        explanation.

From-SVN: r110342
parent 2ef06beb
2006-01-28 Gabriel Dos Reis <gdr@cs.tamu.edu>
* class.c (check_bases): Likewise.
(maybe_warn_about_overly_private_class): Likewise.
(check_field_decls): Likewise.
(layout_empty_base): Likewise.
(layout_virtual_bases): Likewise.
(layout_class_type): Likewise.
* call.c (joust): Pass option code to warning. Use inform for
explanation.
2006-01-28 Mark Mitchell <mark@codesourcery.com> 2006-01-28 Mark Mitchell <mark@codesourcery.com>
PR c++/25999 PR c++/25999
......
...@@ -6029,9 +6029,9 @@ joust (struct z_candidate *cand1, struct z_candidate *cand2, bool warn) ...@@ -6029,9 +6029,9 @@ joust (struct z_candidate *cand1, struct z_candidate *cand2, bool warn)
if (warn) if (warn)
{ {
warning (0, "passing %qT chooses %qT over %qT", warning (OPT_Wsign_promo, "passing %qT chooses %qT over %qT",
type, type1, type2); type, type1, type2);
warning (0, " in call to %qD", w->fn); warning (OPT_Wsign_promo, " in call to %qD", w->fn);
} }
else else
add_warning (w, l); add_warning (w, l);
...@@ -6088,10 +6088,10 @@ joust (struct z_candidate *cand1, struct z_candidate *cand2, bool warn) ...@@ -6088,10 +6088,10 @@ joust (struct z_candidate *cand1, struct z_candidate *cand2, bool warn)
tree source = source_type (w->convs[0]); tree source = source_type (w->convs[0]);
if (! DECL_CONSTRUCTOR_P (w->fn)) if (! DECL_CONSTRUCTOR_P (w->fn))
source = TREE_TYPE (source); source = TREE_TYPE (source);
warning (0, "choosing %qD over %qD", w->fn, l->fn); warning (OPT_Wconversion, "choosing %qD over %qD", w->fn, l->fn);
warning (0, " for conversion from %qT to %qT", warning (OPT_Wconversion, " for conversion from %qT to %qT",
source, w->second_conv->type); source, w->second_conv->type);
warning (0, " because conversion sequence for the argument is better"); inform (" because conversion sequence for the argument is better");
} }
else else
add_warning (w, l); add_warning (w, l);
......
...@@ -1227,8 +1227,9 @@ check_bases (tree t, ...@@ -1227,8 +1227,9 @@ check_bases (tree t,
/* Effective C++ rule 14. We only need to check TYPE_POLYMORPHIC_P /* Effective C++ rule 14. We only need to check TYPE_POLYMORPHIC_P
here because the case of virtual functions but non-virtual here because the case of virtual functions but non-virtual
dtor is handled in finish_struct_1. */ dtor is handled in finish_struct_1. */
if (warn_ecpp && ! TYPE_POLYMORPHIC_P (basetype)) if (!TYPE_POLYMORPHIC_P (basetype))
warning (0, "base class %q#T has a non-virtual destructor", basetype); warning (OPT_Weffc__,
"base class %q#T has a non-virtual destructor", basetype);
/* If the base class doesn't have copy constructors or /* If the base class doesn't have copy constructors or
assignment operators that take const references, then the assignment operators that take const references, then the
...@@ -1542,7 +1543,8 @@ maybe_warn_about_overly_private_class (tree t) ...@@ -1542,7 +1543,8 @@ maybe_warn_about_overly_private_class (tree t)
} }
if (!has_nonprivate_method) if (!has_nonprivate_method)
{ {
warning (0, "all member functions in class %qT are private", t); warning (OPT_Wctor_dtor_privacy,
"all member functions in class %qT are private", t);
return; return;
} }
} }
...@@ -1553,7 +1555,8 @@ maybe_warn_about_overly_private_class (tree t) ...@@ -1553,7 +1555,8 @@ maybe_warn_about_overly_private_class (tree t)
fn = CLASSTYPE_DESTRUCTORS (t); fn = CLASSTYPE_DESTRUCTORS (t);
if (fn && TREE_PRIVATE (fn)) if (fn && TREE_PRIVATE (fn))
{ {
warning (0, "%q#T only defines a private destructor and has no friends", warning (OPT_Wctor_dtor_privacy,
"%q#T only defines a private destructor and has no friends",
t); t);
return; return;
} }
...@@ -1596,7 +1599,8 @@ maybe_warn_about_overly_private_class (tree t) ...@@ -1596,7 +1599,8 @@ maybe_warn_about_overly_private_class (tree t)
if (nonprivate_ctor == 0) if (nonprivate_ctor == 0)
{ {
warning (0, "%q#T only defines private constructors and has no friends", warning (OPT_Wctor_dtor_privacy,
"%q#T only defines private constructors and has no friends",
t); t);
return; return;
} }
...@@ -3032,12 +3036,14 @@ check_field_decls (tree t, tree *access_decls, ...@@ -3032,12 +3036,14 @@ check_field_decls (tree t, tree *access_decls,
if (! TYPE_HAS_INIT_REF (t)) if (! TYPE_HAS_INIT_REF (t))
{ {
warning (0, " but does not override %<%T(const %T&)%>", t, t); warning (OPT_Weffc__,
if (! TYPE_HAS_ASSIGN_REF (t)) " but does not override %<%T(const %T&)%>", t, t);
warning (0, " or %<operator=(const %T&)%>", t); if (!TYPE_HAS_ASSIGN_REF (t))
warning (OPT_Weffc__, " or %<operator=(const %T&)%>", t);
} }
else if (! TYPE_HAS_ASSIGN_REF (t)) else if (! TYPE_HAS_ASSIGN_REF (t))
warning (0, " but does not override %<operator=(const %T&)%>", t); warning (OPT_Weffc__,
" but does not override %<operator=(const %T&)%>", t);
} }
...@@ -3492,8 +3498,9 @@ layout_empty_base (tree binfo, tree eoc, splay_tree offsets) ...@@ -3492,8 +3498,9 @@ layout_empty_base (tree binfo, tree eoc, splay_tree offsets)
if (abi_version_at_least (2)) if (abi_version_at_least (2))
propagate_binfo_offsets propagate_binfo_offsets
(binfo, size_diffop (size_zero_node, BINFO_OFFSET (binfo))); (binfo, size_diffop (size_zero_node, BINFO_OFFSET (binfo)));
else if (warn_abi) else
warning (0, "offset of empty base %qT may not be ABI-compliant and may" warning (OPT_Wabi,
"offset of empty base %qT may not be ABI-compliant and may"
"change in a future version of GCC", "change in a future version of GCC",
BINFO_TYPE (binfo)); BINFO_TYPE (binfo));
} }
...@@ -3604,8 +3611,9 @@ build_base_field (record_layout_info rli, tree binfo, ...@@ -3604,8 +3611,9 @@ build_base_field (record_layout_info rli, tree binfo,
{ {
if (abi_version_at_least (2)) if (abi_version_at_least (2))
CLASSTYPE_NEARLY_EMPTY_P (t) = 0; CLASSTYPE_NEARLY_EMPTY_P (t) = 0;
else if (warn_abi) else
warning (0, "class %qT will be considered nearly empty in a " warning (OPT_Wabi,
"class %qT will be considered nearly empty in a "
"future version of GCC", t); "future version of GCC", t);
} }
} }
...@@ -4349,7 +4357,8 @@ layout_virtual_bases (record_layout_info rli, splay_tree offsets) ...@@ -4349,7 +4357,8 @@ layout_virtual_bases (record_layout_info rli, splay_tree offsets)
CLASSTYPE_ALIGN (basetype)), CLASSTYPE_ALIGN (basetype)),
bitsize_unit_node), bitsize_unit_node),
BINFO_OFFSET (vbase)))) BINFO_OFFSET (vbase))))
warning (0, "offset of virtual base %qT is not ABI-compliant and " warning (OPT_Wabi,
"offset of virtual base %qT is not ABI-compliant and "
"may change in a future version of GCC", "may change in a future version of GCC",
basetype); basetype);
...@@ -4636,8 +4645,8 @@ layout_class_type (tree t, tree *virtuals_p) ...@@ -4636,8 +4645,8 @@ layout_class_type (tree t, tree *virtuals_p)
padding = DECL_SIZE (field); padding = DECL_SIZE (field);
else else
{ {
if (warn_abi && TREE_CODE (t) == UNION_TYPE) if (TREE_CODE (t) == UNION_TYPE)
warning (0, "size assigned to %qT may not be " warning (OPT_Wabi, "size assigned to %qT may not be "
"ABI-compliant and may change in a future " "ABI-compliant and may change in a future "
"version of GCC", "version of GCC",
t); t);
...@@ -4676,7 +4685,8 @@ layout_class_type (tree t, tree *virtuals_p) ...@@ -4676,7 +4685,8 @@ layout_class_type (tree t, tree *virtuals_p)
&& DECL_MODE (field) != TYPE_MODE (type)) && DECL_MODE (field) != TYPE_MODE (type))
/* Versions of G++ before G++ 3.4 did not reset the /* Versions of G++ before G++ 3.4 did not reset the
DECL_MODE. */ DECL_MODE. */
warning (0, "the offset of %qD may not be ABI-compliant and may " warning (OPT_Wabi,
"the offset of %qD may not be ABI-compliant and may "
"change in a future version of GCC", field); "change in a future version of GCC", field);
} }
else else
...@@ -4704,7 +4714,7 @@ layout_class_type (tree t, tree *virtuals_p) ...@@ -4704,7 +4714,7 @@ layout_class_type (tree t, tree *virtuals_p)
&& !integer_zerop (size_binop (TRUNC_MOD_EXPR, && !integer_zerop (size_binop (TRUNC_MOD_EXPR,
DECL_FIELD_BIT_OFFSET (field), DECL_FIELD_BIT_OFFSET (field),
bitsize_unit_node))) bitsize_unit_node)))
warning (0, "offset of %q+D is not ABI-compliant and may " warning (OPT_Wabi, "offset of %q+D is not ABI-compliant and may "
"change in a future version of GCC", field); "change in a future version of GCC", field);
/* G++ used to use DECL_FIELD_OFFSET as if it were the byte /* G++ used to use DECL_FIELD_OFFSET as if it were the byte
...@@ -4713,7 +4723,7 @@ layout_class_type (tree t, tree *virtuals_p) ...@@ -4713,7 +4723,7 @@ layout_class_type (tree t, tree *virtuals_p)
&& !tree_int_cst_equal (DECL_FIELD_OFFSET (field), && !tree_int_cst_equal (DECL_FIELD_OFFSET (field),
byte_position (field)) byte_position (field))
&& contains_empty_class_p (TREE_TYPE (field))) && contains_empty_class_p (TREE_TYPE (field)))
warning (0, "%q+D contains empty classes which may cause base " warning (OPT_Wabi, "%q+D contains empty classes which may cause base "
"classes to be placed at different locations in a " "classes to be placed at different locations in a "
"future version of GCC", field); "future version of GCC", field);
...@@ -4772,7 +4782,8 @@ layout_class_type (tree t, tree *virtuals_p) ...@@ -4772,7 +4782,8 @@ layout_class_type (tree t, tree *virtuals_p)
TYPE_SIZE (base_t) = bitsize_zero_node; TYPE_SIZE (base_t) = bitsize_zero_node;
TYPE_SIZE_UNIT (base_t) = size_zero_node; TYPE_SIZE_UNIT (base_t) = size_zero_node;
if (warn_abi && !integer_zerop (rli_size_unit_so_far (rli))) if (warn_abi && !integer_zerop (rli_size_unit_so_far (rli)))
warning (0, "layout of classes derived from empty class %qT " warning (OPT_Wabi,
"layout of classes derived from empty class %qT "
"may change in a future version of GCC", "may change in a future version of GCC",
t); t);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment