Browse Source

* 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 -

Jonas Maebe 13 years ago
parent
commit
cfca607b9b
3 changed files with 45 additions and 2 deletions
  1. 1 0
      .gitattributes
  2. 5 2
      compiler/jvm/pjvm.pas
  3. 39 0
      tests/test/jvm/tset7.pp

+ 1 - 0
.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/trange3.pp svneol=native#text/plain
 tests/test/jvm/tset1.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/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/tstr.pp svneol=native#text/plain
 tests/test/jvm/tstring1.pp svneol=native#text/plain
 tests/test/jvm/tstring1.pp svneol=native#text/plain
 tests/test/jvm/tstring9.pp svneol=native#text/plain
 tests/test/jvm/tstring9.pp svneol=native#text/plain

+ 5 - 2
compiler/jvm/pjvm.pas

@@ -314,8 +314,11 @@ implementation
         enumclass.symtable.insert(temptypesym);
         enumclass.symtable.insert(temptypesym);
         { but the name of the class as far as the JVM is concerned will match
         { 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
           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)
           enumclass.objextname:=stringdup(name)
         else
         else
           { for local types, use a unique name to prevent conflicts (since such
           { for local types, use a unique name to prevent conflicts (since such

+ 39 - 0
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.