Skip to content

Commit f79a088

Browse files
committed
- Correct truncation on 64-bit platforms git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@9653 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 4eac2fb commit f79a088

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Parser/Modelica.g

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -984,11 +984,13 @@ primary returns [void* ast] @declarations {
984984
if (((long)1<<(RML_SIZE_INT*8-2))-1 >= l) {
985985
$ast = Absyn__INTEGER(RML_IMMEDIATE(RML_TAGFIXNUM(l))); /* We can't use mk_icon here - it takes "int"; not "long" */
986986
} else {
987-
if (l > ((long)1<<30)-1) {
988-
c_add_source_message(2, "SYNTAX", "Warning", "\%s-bit signed integers! Truncating integer: \%s to 1073741823",
987+
long lt = ((long)1<<(RML_SIZE_INT == 8 ? 62 : 30))-1;
988+
if (l > lt) {
989+
const char *msg = RML_SIZE_INT != 8 ? "\%s-bit signed integers! Truncating integer: \%s to 1073741823" : "\%s-bit signed integers! Truncating integer: \%s to 4611686018427387903";
990+
c_add_source_message(2, "SYNTAX", "Warning", msg,
989991
args, 2, $start->line, $start->charPosition+1, LT(1)->line, LT(1)->charPosition+1,
990992
ModelicaParser_readonly, ModelicaParser_filename_C);
991-
$ast = Absyn__INTEGER(mk_icon(1073741823));
993+
$ast = Absyn__INTEGER(RML_IMMEDIATE(RML_TAGFIXNUM(lt)));
992994
} else {
993995
$ast = Absyn__REAL(mk_rcon((double)l));
994996
}

0 commit comments

Comments
 (0)