
Module: ppl/ppl Branch: master Commit: 3ab4d6ede25cc2a5266a4d73da06e7908bf2074d URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=3ab4d6ede25cc...
Author: Roberto Bagnara bagnara@cs.unipr.it Date: Fri Oct 28 17:43:43 2011 +0200
Avoid implementation-defined behavior by having bitfields of explicit unsigned integral type. Detected by ECLAIR service bitftype.
---
src/Concrete_Expression.defs.hh | 11 +++++------ src/Concrete_Expression.inlines.hh | 12 ++++++++---- 2 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/src/Concrete_Expression.defs.hh b/src/Concrete_Expression.defs.hh index f7ce588..7860a57 100644 --- a/src/Concrete_Expression.defs.hh +++ b/src/Concrete_Expression.defs.hh @@ -66,8 +66,7 @@ public: The behavior is undefined if \p *this does not encode a bounded integer type. */ - Bounded_Integer_Type_Width - bounded_integer_type_width() const; + Bounded_Integer_Type_Width bounded_integer_type_width() const;
/*! \brief Returns the representation of the bounded integer type encoded by @@ -104,10 +103,10 @@ private: //! A 32-bit word encoding the type. struct Implementation { unsigned int bounded_integer:1; - Bounded_Integer_Type_Width bounded_integer_type_width:23; - Bounded_Integer_Type_Representation bounded_integer_type_representation:2; - Bounded_Integer_Type_Overflow bounded_integer_type_overflow:2; - Floating_Point_Format floating_point_format:4; + unsigned int bounded_integer_type_width:23; + unsigned int bounded_integer_type_representation:2; + unsigned int bounded_integer_type_overflow:2; + unsigned int floating_point_format:4; };
//! Constructor from \p implementation. diff --git a/src/Concrete_Expression.inlines.hh b/src/Concrete_Expression.inlines.hh index 952ada9..b12963a 100644 --- a/src/Concrete_Expression.inlines.hh +++ b/src/Concrete_Expression.inlines.hh @@ -71,22 +71,26 @@ Concrete_Expression_Type::is_floating_point() const {
inline Bounded_Integer_Type_Width Concrete_Expression_Type::bounded_integer_type_width() const { - return impl.bounded_integer_type_width; + unsigned int u = impl.bounded_integer_type_width; + return static_cast<Bounded_Integer_Type_Width>(u); }
inline Bounded_Integer_Type_Representation Concrete_Expression_Type::bounded_integer_type_representation() const { - return impl.bounded_integer_type_representation; + unsigned int u = impl.bounded_integer_type_representation; + return static_cast<Bounded_Integer_Type_Representation>(u); }
inline Bounded_Integer_Type_Overflow Concrete_Expression_Type::bounded_integer_type_overflow() const { - return impl.bounded_integer_type_overflow; + unsigned int u = impl.bounded_integer_type_overflow; + return static_cast<Bounded_Integer_Type_Overflow>(u); }
inline Floating_Point_Format Concrete_Expression_Type::floating_point_format() const { - return impl.floating_point_format; + unsigned int u = impl.floating_point_format; + return static_cast<Floating_Point_Format>(u); }
template <typename Target>