From cfca607b9bab84694eb5c8303fbebcfeb2a63628 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Fri, 28 Oct 2011 21:19:12 +0000 Subject: [PATCH] * in case of an enum without a type name (e.g., "type xx = set of (ea,eb)"), set the external name of the underlying class type to the internal name instead of to an (invalid) empty string git-svn-id: branches/jvmbackend@19555 - --- .gitattributes | 1 + compiler/jvm/pjvm.pas | 7 +++++-- tests/test/jvm/tset7.pp | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 tests/test/jvm/tset7.pp diff --git a/.gitattributes b/.gitattributes index fcef7ee5f2..474e5014d1 100644 --- a/.gitattributes +++ b/.gitattributes @@ -9804,6 +9804,7 @@ tests/test/jvm/trange2.pp svneol=native#text/plain tests/test/jvm/trange3.pp svneol=native#text/plain tests/test/jvm/tset1.pp svneol=native#text/plain tests/test/jvm/tset3.pp svneol=native#text/plain +tests/test/jvm/tset7.pp svneol=native#text/plain tests/test/jvm/tstr.pp svneol=native#text/plain tests/test/jvm/tstring1.pp svneol=native#text/plain tests/test/jvm/tstring9.pp svneol=native#text/plain diff --git a/compiler/jvm/pjvm.pas b/compiler/jvm/pjvm.pas index d8ab120b31..a59898d003 100644 --- a/compiler/jvm/pjvm.pas +++ b/compiler/jvm/pjvm.pas @@ -314,8 +314,11 @@ implementation enumclass.symtable.insert(temptypesym); { but the name of the class as far as the JVM is concerned will match the enum's original name (the enum type itself won't be output in - any class file, so no conflict there) } - if not islocal then + any class file, so no conflict there) + + name can be empty in case of declaration such as "set of (ea,eb)" } + if not islocal and + (name <> '') then enumclass.objextname:=stringdup(name) else { for local types, use a unique name to prevent conflicts (since such diff --git a/tests/test/jvm/tset7.pp b/tests/test/jvm/tset7.pp new file mode 100644 index 0000000000..db1e2132d5 --- /dev/null +++ b/tests/test/jvm/tset7.pp @@ -0,0 +1,39 @@ +program tset7; + +{ test for subsetreg sets } + +{$packset 1} + +type + ta = 0..7; + tr = record + b: byte; + a: set of ta; + w: word; + end; + + +procedure test(r: tr); +var + b: ta; +begin + b := 6; + if (r.b<>101) or + (r.w<>$abcd) or + (5 in r.a) or + (b in r.a) or + not(7 in r.a) or + ([1..3] * r.a <> [2..3]) then + halt(1); +end; + +var + r: tr; + inlineenumdefset: set of (inline1,inline2); +begin + r.b:=101; + r.w:=$abcd; + r.a:=[2..3]; + include(r.a,7); + test(r); +end.