Ver Fonte

* support for constant char/bool/enum indices in typed constant
index expressions (mantis #34055)
* prevent all indirect structure indexing instead of only
ansi/wide/unicodestrings

git-svn-id: trunk@40010 -

Jonas Maebe há 6 anos atrás
pai
commit
2a3eeab96d
3 ficheiros alterados com 30 adições e 3 exclusões
  1. 1 0
      .gitattributes
  2. 5 3
      compiler/ngtcon.pas
  3. 24 0
      tests/webtbs/tw34055.pp

+ 1 - 0
.gitattributes

@@ -16392,6 +16392,7 @@ tests/webtbs/tw33898.pp -text svneol=native#text/pascal
 tests/webtbs/tw3402.pp svneol=native#text/plain
 tests/webtbs/tw34021.pp -text svneol=native#text/pascal
 tests/webtbs/tw34037.pp svneol=native#text/pascal
+tests/webtbs/tw34055.pp svneol=native#text/plain
 tests/webtbs/tw3411.pp svneol=native#text/plain
 tests/webtbs/tw34124.pp svneol=native#text/pascal
 tests/webtbs/tw3418.pp svneol=native#text/plain

+ 5 - 3
compiler/ngtcon.pas

@@ -916,9 +916,11 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
                        case hp.nodetype of
                          vecn :
                            begin
-                             if is_constintnode(tvecnode(hp).right) and
-                                not is_ansistring(tvecnode(hp).left.resultdef) and
-                                not is_wide_or_unicode_string(tvecnode(hp).left.resultdef) then
+                             if (is_constintnode(tvecnode(hp).right) or
+                                 is_constenumnode(tvecnode(hp).right) or
+                                 is_constcharnode(tvecnode(hp).right) or
+                                 is_constboolnode(tvecnode(hp).right)) and
+                                not is_implicit_array_pointer(tvecnode(hp).left.resultdef) then
                                ftcb.queue_vecn(tvecnode(hp).left.resultdef,get_ordinal_value(tvecnode(hp).right))
                              else
                                Message(parser_e_illegal_expression);

+ 24 - 0
tests/webtbs/tw34055.pp

@@ -0,0 +1,24 @@
+{$mode objfpc}
+
+ type
+  TDOS_FIELDNAMES = (
+                      Dos_Signature, // ord = 0
+                      Dos_OffsetToNewExecutable // ord = 1
+                    );
+
+
+
+const
+  DosFieldLabelsB : array[TDOS_FIELDNAMES]
+                        of pwidechar =
+  (
+    'DOS signature',
+    'offset to new executable'
+  );
+
+  d : ppwidechar = @DosFieldLabelsB[Dos_OffsetToNewExecutable];
+
+begin
+  if d<>@DosFieldLabelsB[Dos_OffsetToNewExecutable] then
+    halt(1);
+end.