Commit 30ee7e1d authored by Botond Baranyi's avatar Botond Baranyi Committed by Gerrit Code Review
Browse files

Merge "OER regression test fixes"

parents 3fbc089c 014b3866
......@@ -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;
......
......@@ -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(); }
};
/**
......
......@@ -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());
}
......
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