From 57963798c338b0b73e032e9288003fd462f8b954 Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Tue, 22 Aug 2017 15:33:14 +0300 Subject: [PATCH] =?utf8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5?= =?utf8?q?=D0=BD=D0=B0=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B0?= =?utf8?q?=20VAR-=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82=D1=80=D0=BE?= =?utf8?q?=D0=B2-=D0=B7=D0=B0=D0=BF=D0=B8=D1=81=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Test.obn | 22 +++++++++++++++------- obn-run-tests.sh | 3 +++ src/main.c | 2 +- src/oberon-type-compat.c | 2 +- src/oberon.c | 2 +- tests/Test23A.obn | 25 +++++++++++++++++++++++++ tests/Test23B.obn | 24 ++++++++++++++++++++++++ 7 files changed, 70 insertions(+), 10 deletions(-) create mode 100644 tests/Test23A.obn create mode 100644 tests/Test23B.obn diff --git a/Test.obn b/Test.obn index e4eeec3..b9b14ae 100644 --- a/Test.obn +++ b/Test.obn @@ -1,15 +1,23 @@ MODULE Test; TYPE - Rider = RECORD i : INTEGER END; + Stream* = POINTER TO Handle; + Handle = RECORD END; -PROCEDURE X; - VAR - r : Rider; + Writer* = RECORD END; + + Printer* = RECORD (Writer) END; + +VAR + s : Stream; + o : Writer; + out : Printer; + +PROCEDURE SetStream(VAR w : Writer; stream : Stream); BEGIN - r.i := 666; -END X; +END SetStream; BEGIN - X; + SetStream(o, s); + SetStream(out, s); END Test. diff --git a/obn-run-tests.sh b/obn-run-tests.sh index b9116ff..57756c3 100755 --- a/obn-run-tests.sh +++ b/obn-run-tests.sh @@ -92,3 +92,6 @@ maketest Test19 maketest Test20 maketest Test21 maketest Test22 + +makecomp Test23A +makefail Test23B diff --git a/src/main.c b/src/main.c index 9d471e6..05ea892 100644 --- a/src/main.c +++ b/src/main.c @@ -49,7 +49,7 @@ open_file(struct string_stack * path, const char * ext, const char * name, const size_t len = strlen(fname); res -> source = malloc(len + 1); - memcpy(res -> source, fname, len); + memcpy(res -> source, fname, len + 1); return fp; } diff --git a/src/oberon-type-compat.c b/src/oberon-type-compat.c index 964f0a0..ab5419d 100644 --- a/src/oberon-type-compat.c +++ b/src/oberon-type-compat.c @@ -474,7 +474,7 @@ oberon_is_compatible_var_param(oberon_type_t * Tf, oberon_type_t * Ta) /* фактический параметр может быть указателем любого типа. */ return oberon_is_some_types(Tf, Ta) - || (oberon_is_record_type(Tf) && oberon_extension_of(Ta, Tf)) + || (oberon_is_record_type(Tf) && oberon_extension_of(Tf, Ta)) || (oberon_is_system_byte_type(Tf) && (oberon_is_char_type(Ta) || oberon_is_byte_type(Ta))) || (oberon_is_array_of_system_byte_type(Tf)) || (oberon_is_system_ptr_type(Tf)); diff --git a/src/oberon.c b/src/oberon.c index 437e769..4a740d8 100644 --- a/src/oberon.c +++ b/src/oberon.c @@ -4535,7 +4535,7 @@ oberon_make_ord_call(oberon_context_t * ctx, int num_args, oberon_expr_t * list_ } else { - expr = oberon_cast_expr(ctx, arg, ctx -> int_type); + expr = oberon_cast_expr(ctx, arg, ctx -> shortint_type); } return expr; } diff --git a/tests/Test23A.obn b/tests/Test23A.obn new file mode 100644 index 0000000..e8cf446 --- /dev/null +++ b/tests/Test23A.obn @@ -0,0 +1,25 @@ +MODULE Test23A; + +TYPE + Stream* = POINTER TO Handle; + Handle = RECORD END; + + Writer* = RECORD END; + + Printer* = RECORD (Writer) END; + +VAR + s : Stream; + o : Writer; + out : Printer; + +PROCEDURE SetStream(VAR w : Writer; stream : Stream); +BEGIN +END SetStream; + +BEGIN + SetStream(o, s); + SetStream(out, s); +END Test23A. + +Проверка VAR-параметров-записи. Должно компилироваться. diff --git a/tests/Test23B.obn b/tests/Test23B.obn new file mode 100644 index 0000000..518fb03 --- /dev/null +++ b/tests/Test23B.obn @@ -0,0 +1,24 @@ +MODULE Test23B; + +TYPE + Stream* = POINTER TO Handle; + Handle = RECORD END; + + Writer* = RECORD END; + + Printer* = RECORD (Writer) END; + +VAR + s : Stream; + o : Writer; + out : Printer; + +PROCEDURE SetStream(VAR w : Writer; stream : Stream); +BEGIN +END SetStream; + +BEGIN + SetStream(s, s); +END Test23B. + +Проверка VAR-параметров-записи. Должно проваливаться. -- 2.29.2