[GIT] ppl/ppl(master): Fixed some warnings.

Module: ppl/ppl Branch: master Commit: 15650222d5358a202411066142ab134b03cbea1e URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=15650222d5358...
Author: Abramo Bagnara abramo.bagnara@gmail.com Date: Mon Jun 6 16:34:59 2011 +0200
Fixed some warnings.
---
src/Grid_public.cc | 6 +++--- src/Interval.inlines.hh | 13 ++++++------- src/Interval.templates.hh | 8 ++++---- src/wrap_assign.hh | 2 +- 4 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/src/Grid_public.cc b/src/Grid_public.cc index 47b8437..82e64a3 100644 --- a/src/Grid_public.cc +++ b/src/Grid_public.cc @@ -2735,7 +2735,7 @@ PPL::Grid::wrap_assign(const Variables_Set& vars, PPL_DIRTY_TEMP_COEFFICIENT(v_n); PPL_DIRTY_TEMP_COEFFICIENT(v_d); for (Variables_Set::const_iterator i = vars.begin(), - vars_end = vars.end(); i != vars.end(); ++i) { + vars_end = vars.end(); i != vars_end; ++i) { const Variable x = Variable(*i); // Find the frequency and a value for `x' in `gr'. if (!gr.frequency_no_check(x, f_n, f_d, v_n, v_d)) @@ -2817,7 +2817,7 @@ PPL::Grid::wrap_assign(const Variables_Set& vars, max_value *= div; min_value *= div; for (Variables_Set::const_iterator i = vars.begin(), - vars_end = vars.end(); i != vars.end(); ++i) { + vars_end = vars.end(); i != vars_end; ++i) { const Variable x = Variable(*i); if (!gr.bounds_no_check(x)) { // `x' is not a constant in `gr'. @@ -2886,7 +2886,7 @@ PPL::Grid::drop_some_non_integer_points(const Variables_Set& vars, // in vars. All points in \p *this with non-integral coordinates for // the dimensions in vars are removed. for (Variables_Set::const_iterator i = vars.begin(), - vars_end = vars.end(); i != vars.end(); ++i) + vars_end = vars.end(); i != vars_end; ++i) add_congruence(Variable(*i) %= 0);
PPL_ASSERT(OK()); diff --git a/src/Interval.inlines.hh b/src/Interval.inlines.hh index 2fdba70..85cc815 100644 --- a/src/Interval.inlines.hh +++ b/src/Interval.inlines.hh @@ -352,13 +352,12 @@ Interval<To_Boundary, To_Info>::intersect_assign(const From1& x, to_info.clear(); if (!intersect_restriction(to_info, x, y)) return assign(EMPTY); - Result rl, ru; - rl = max_assign(LOWER, lower(), to_info, - LOWER, f_lower(x), f_info(x), - LOWER, f_lower(y), f_info(y)); - ru = min_assign(UPPER, upper(), to_info, - UPPER, f_upper(x), f_info(x), - UPPER, f_upper(y), f_info(y)); + max_assign(LOWER, lower(), to_info, + LOWER, f_lower(x), f_info(x), + LOWER, f_lower(y), f_info(y)); + min_assign(UPPER, upper(), to_info, + UPPER, f_upper(x), f_info(x), + UPPER, f_upper(y), f_info(y)); assign_or_swap(info(), to_info); PPL_ASSERT(OK()); return I_NOT_EMPTY; diff --git a/src/Interval.templates.hh b/src/Interval.templates.hh index 9f83797..50a1f0c 100644 --- a/src/Interval.templates.hh +++ b/src/Interval.templates.hh @@ -37,6 +37,8 @@ Interval<Boundary, Info>::lower_extend(const C& c) { switch (c.rel()) { case V_LGE: return lower_extend(); + default: + PPL_ASSERT(false); case V_NAN: return I_NOT_EMPTY | I_EXACT | I_UNCHANGED; case V_GT: @@ -46,8 +48,6 @@ Interval<Boundary, Info>::lower_extend(const C& c) { case V_EQ: open = false; break; - default: - PPL_ASSERT(false); } min_assign(LOWER, lower(), info(), LOWER, c.value(), f_info(c.value(), open)); PPL_ASSERT(OK()); @@ -63,6 +63,8 @@ Interval<Boundary, Info>::upper_extend(const C& c) { switch (c.rel()) { case V_LGE: return lower_extend(); + default: + PPL_ASSERT(false); case V_NAN: return I_NOT_EMPTY | I_EXACT | I_UNCHANGED; case V_LT: @@ -72,8 +74,6 @@ Interval<Boundary, Info>::upper_extend(const C& c) { case V_EQ: open = false; break; - default: - PPL_ASSERT(false); } max_assign(UPPER, upper(), info(), UPPER, c.value(), f_info(c.value(), open)); PPL_ASSERT(OK()); diff --git a/src/wrap_assign.hh b/src/wrap_assign.hh index cbddcd3..1c54cc0 100644 --- a/src/wrap_assign.hh +++ b/src/wrap_assign.hh @@ -124,7 +124,7 @@ wrap_assign_col(PSET& dest, if (pcs != 0) p.refine_with_constraints(*pcs); for (Variables_Set::const_iterator i = vars.begin(), - vars_end = vars.end(); i != vars.end(); ++i) { + vars_end = vars.end(); i != vars_end; ++i) { const Variable x = Variable(*i); p.refine_with_constraint(min_value <= x); p.refine_with_constraint(x <= max_value);

Abramo, greetings again!
On Mon, Jun 6, 2011 at 8:35 AM, Abramo Bagnara abramo.bagnara@gmail.com wrote:
Fixed some warnings.
diff --git a/src/Grid_public.cc b/src/Grid_public.cc index 47b8437..82e64a3 100644 --- a/src/Grid_public.cc +++ b/src/Grid_public.cc @@ -2735,7 +2735,7 @@ PPL::Grid::wrap_assign(const Variables_Set& vars, PPL_DIRTY_TEMP_COEFFICIENT(v_n); PPL_DIRTY_TEMP_COEFFICIENT(v_d); for (Variables_Set::const_iterator i = vars.begin(),
- vars_end = vars.end(); i != vars.end(); ++i) {
- vars_end = vars.end(); i != vars_end; ++i) {
const Variable x = Variable(*i); // Find the frequency and a value for `x' in `gr'. if (!gr.frequency_no_check(x, f_n, f_d, v_n, v_d))
Have you considered using BOOST_FOREACH or something similar here? It should allow you to replace that loop header with something as simple as:
BOOST_FOREACH( Variables_Set::const_iterator i, vars ) { ...
It even allows for iterating using references, which would remove the initial assignment in that loop:
BOOST_FOREACH( const Variable & x, vars ) { ...
The author of BOOST_FOREACH goes into excruciating detail in this article:
http://www.artima.com/cppsource/foreach.html
I don't know if you want to drag in BOOST_FOREACH in particular, though; I believe it relies on Boost.Range, and there may or may not be issues with shipping Boost-licensed code within the GPL'd PPL.
It's easy enough to cook one up to match the first usage; it's not perfect (evaluates collection argument twice) but might be worth looking into:
#define FOREACH( TYPE, ITER, COLLECTION ) \ for ( TYPE ITER = COLLECTION.begin(), \ ITER##_end = COLLECTION.end(); \ ITER != ITER##_end; \ ++ITER )
And, of course, this will all go away when C++0x is fully supported. :-/
(Having said that, g++ should support the new "for" syntax as of 4.6, so perhaps using the FOREACH macro and conditionalizing it on the basis of g++ version or other indicator of C++0x support might actually be a reasonable thing to do...)
Hope you find this interesting.
Thanks once again for the great work on the library!
Best regards, Anthony Foiani
participants (2)
-
Abramo Bagnara
-
Anthony Foiani