From 536e62e3693fde8daea4195afd421422e671a707 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D0=BE=D0=BD=D0=B4=D0=B0=D1=80=D0=B5=D0=B2=20=D0=98?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD?= Date: Sun, 9 Feb 2020 11:33:37 +0100 Subject: [PATCH] bug fix #2187 --- NETGenerator/NETGenerator.cs | 10 +++++++++- TestSuite/errors/err0345_marshal.pas | 6 ++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 TestSuite/errors/err0345_marshal.pas diff --git a/NETGenerator/NETGenerator.cs b/NETGenerator/NETGenerator.cs index 379440177..48cd70fef 100644 --- a/NETGenerator/NETGenerator.cs +++ b/NETGenerator/NETGenerator.cs @@ -1833,7 +1833,15 @@ namespace PascalABCCompiler.NETGenerator if (attrs[i].qualifier == SemanticTree.attribute_qualifier_kind.return_kind) { var constr = (attrs[i].AttributeConstructor is ICompiledConstructorNode) ? (attrs[i].AttributeConstructor as ICompiledConstructorNode).constructor_info : helper.GetConstructor(attrs[i].AttributeConstructor).cnstr; - mb.SetMarshal(UnmanagedMarshal.DefineUnmanagedMarshal((UnmanagedType)attrs[i].Arguments[0].value)); + + try + { + mb.SetMarshal(UnmanagedMarshal.DefineUnmanagedMarshal((UnmanagedType)attrs[i].Arguments[0].value)); + } + catch(ArgumentException ex) + { + throw new PascalABCCompiler.Errors.CommonCompilerError(ex.Message.Replace(", переданный для DefineUnmanagedMarshal,",""), attrs[i].Location.document.file_name, attrs[i].Location.begin_line_num, attrs[i].Location.begin_column_num); + } } else mb.SetCustomAttribute(cab); diff --git a/TestSuite/errors/err0345_marshal.pas b/TestSuite/errors/err0345_marshal.pas new file mode 100644 index 000000000..a819a15b0 --- /dev/null +++ b/TestSuite/errors/err0345_marshal.pas @@ -0,0 +1,6 @@ +program err0345_marshal; +[Result: System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.SafeArray)] +function f1: array of byte; +external 'any.dll'; + +begin end. \ No newline at end of file