diff --git a/compiler2/Type_chk.cc b/compiler2/Type_chk.cc index 397f8e901df387dbeb5357c8b2444665b8e90ef2..b23380e4df29f48cab9a2cc96be4dd0a07b978fc 100644 --- a/compiler2/Type_chk.cc +++ b/compiler2/Type_chk.cc @@ -3004,45 +3004,50 @@ void Type::chk_oer() { break; case T_INT_A: { if (is_constrained()) { - Location loc; - int_limit_t upper = get_sub_type()->get_root()->get_int_limit(true, &loc); - int_limit_t lower = get_sub_type()->get_root()->get_int_limit(false, &loc); - bool lower_inf = lower.get_type() != int_limit_t::NUMBER; - bool upper_inf = upper.get_type() != int_limit_t::NUMBER; - if (lower_inf || upper_inf) { - oerattrib->signed_ = lower_inf; - oerattrib->bytes = -1; - } else { - int_val_t low = lower.get_value(); - int_val_t up = upper.get_value(); - if (low < 0) { - oerattrib->signed_ = true; - if (low >= -128 && up <= 127) { - oerattrib->bytes = 1; - } else if (low >= -32768 && up <= 32767) { - oerattrib->bytes = 2; - } else if (low >= -2147483648 && up <= 2147483647) { - oerattrib->bytes = 4; - } else if ((low+1) >= -9223372036854775807LL && up <= 9223372036854775807LL) { - oerattrib->bytes = 8; - } else { - oerattrib->bytes = -1; - } + if (get_sub_type()->is_integer_subtype_notempty()) { + Location loc; + int_limit_t upper = get_sub_type()->get_int_limit(true, &loc); + int_limit_t lower = get_sub_type()->get_int_limit(false, &loc); + bool lower_inf = lower.get_type() != int_limit_t::NUMBER; + bool upper_inf = upper.get_type() != int_limit_t::NUMBER; + if (lower_inf || upper_inf) { + oerattrib->signed_ = lower_inf; + oerattrib->bytes = -1; } else { - static int_val_t uns_8_byte("18446744073709551615", NULL); - oerattrib->signed_ = false; - if (up <= 255) { - oerattrib->bytes = 1; - } else if (up <= 65535) { - oerattrib->bytes = 2; - } else if (up <= 4294967295) { - oerattrib->bytes = 4; - } else if (up <= uns_8_byte) { - oerattrib->bytes = 8; + int_val_t low = lower.get_value(); + int_val_t up = upper.get_value(); + if (low < 0) { + oerattrib->signed_ = true; + if (low >= -128 && up <= 127) { + oerattrib->bytes = 1; + } else if (low >= -32768 && up <= 32767) { + oerattrib->bytes = 2; + } else if (low >= -2147483648LL && up <= 2147483647) { + oerattrib->bytes = 4; + } else if ((low+1) >= -9223372036854775807LL && up <= 9223372036854775807LL) { + oerattrib->bytes = 8; + } else { + oerattrib->bytes = -1; + } } else { - oerattrib->bytes = -1; + static int_val_t uns_8_byte("18446744073709551615", NULL); + oerattrib->signed_ = false; + if (up <= 255) { + oerattrib->bytes = 1; + } else if (up <= 65535) { + oerattrib->bytes = 2; + } else if (up <= 4294967295LL) { + oerattrib->bytes = 4; + } else if (up <= uns_8_byte) { + oerattrib->bytes = 8; + } else { + oerattrib->bytes = -1; + } } } + } else { + oerattrib->signed_ = true; + oerattrib->bytes = -1; } } else { oerattrib->signed_ = true; diff --git a/compiler2/subtype.hh b/compiler2/subtype.hh index e839612da301584cfb7e1b60df4e724dc78ec2a2..37d259193d508b1b84a5ac588262c5cfd8fd0394 100644 --- a/compiler2/subtype.hh +++ b/compiler2/subtype.hh @@ -218,6 +218,8 @@ public: bool is_length_compatible(const SubtypeConstraint *p_st) const; bool is_upper_limit_infinity() const; bool is_lower_limit_infinity() const; + bool is_integer_subtype_notempty() const + { return subtype==ST_INTEGER && integer_st && !integer_st->is_empty(); } }; /** diff --git a/compiler2/ttcn3/Attributes.cc b/compiler2/ttcn3/Attributes.cc index 61062dea38e10fd53d4ca440093cb0ae57877ad7..7629ed47a2f80f3d360e3bec3dcd3d2100c30aaf 100644 --- a/compiler2/ttcn3/Attributes.cc +++ b/compiler2/ttcn3/Attributes.cc @@ -666,8 +666,8 @@ namespace Ttcn { (type->has_encoding(Type::CT_RAW)&&ti_type->has_encoding(Type::CT_RAW)) || (type->has_encoding(Type::CT_TEXT)&&ti_type->has_encoding(Type::CT_TEXT)) || (type->has_encoding(Type::CT_XER)&&ti_type->has_encoding(Type::CT_XER)) || - (type->has_encoding(Type::CT_JSON)&&ti_type->has_encoding(Type::CT_JSON))) || - (type->has_encoding(Type::CT_OER)&&ti_type->has_encoding(Type::CT_OER))) { + (type->has_encoding(Type::CT_JSON)&&ti_type->has_encoding(Type::CT_JSON)) || + (type->has_encoding(Type::CT_OER)&&ti_type->has_encoding(Type::CT_OER)))) { act_attr->error("Type `%s' and type `%s' have no common encoding", ti_type->get_typename().c_str(), type->get_typename().c_str()); }