This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[C++] simplify check_for_casting_away_constness


:ADDPATCH c++:

The current check_for_casting_away_constness takes a pointer to
function and a string as arguments, in order to print warnings or
errors for c-casts, static_casts or reinterpret_casts.

Apart from breaking the message string and using warning0 where it
should use warning(OPT_Wcast-qual,""), it really doesn't make sense to
have the warning/error logic outside the function when it could be
perfectly contained within.

The new check_for_casting_away_constness uses just 1 argument that can
be either 1,2 or 3 to denote c-cast, static_cast and reinterpret_cast,
respectively. I wasn't sure about using an enum local to typeck.c. Or
perhaps we should have a more general enum to classify cast types.

Bootstrapped and regression tested.

2007-11-14  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

  * typeck.c (check_for_casting_away_constness): Use 1 single
argument, the type of cast, to decide what diagnostics generate.
  (build_static_cast_1): Remove unused code. Call
check_for_casting_away_constness with cast_type 2.
  (build_reinterpret_cast_1): Call check_for_casting_away_constness
with cast_type 3.
  (build_const_cast_1): Call check_for_casting_away_constness with cast_type 1.

Attachment: fix-cast-away-constness.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]