瀏覽代碼

* allow subtraction/addition of internally generated nodes, resolves #27256

git-svn-id: trunk@29456 -
florian 10 年之前
父節點
當前提交
ccb01d6196
共有 4 個文件被更改,包括 33 次插入5 次删除
  1. 1 0
      .gitattributes
  2. 3 4
      compiler/nadd.pas
  3. 4 1
      compiler/ncal.pas
  4. 25 0
      tests/webtbs/tw27256.pp

+ 1 - 0
.gitattributes

@@ -14189,6 +14189,7 @@ tests/webtbs/tw27185.pp svneol=native#text/pascal
 tests/webtbs/tw2721.pp svneol=native#text/plain
 tests/webtbs/tw2723.pp svneol=native#text/plain
 tests/webtbs/tw2725.pp svneol=native#text/plain
+tests/webtbs/tw27256.pp svneol=native#text/pascal
 tests/webtbs/tw2727.pp svneol=native#text/plain
 tests/webtbs/tw2728.pp svneol=native#text/plain
 tests/webtbs/tw2729.pp svneol=native#text/plain

+ 3 - 4
compiler/nadd.pas

@@ -409,8 +409,7 @@ implementation
           end;
 
         { both are int constants }
-        if (
-            (
+        if  (
              is_constintnode(left) and
              is_constintnode(right)
             ) or
@@ -422,7 +421,7 @@ implementation
             (
              is_constenumnode(left) and
              is_constenumnode(right) and
-             allowenumop(nodetype))
+             (allowenumop(nodetype) or (nf_internal in flags))
             ) or
             (
              (lt = pointerconstn) and
@@ -2140,7 +2139,7 @@ implementation
          { enums }
          else if (ld.typ=enumdef) and (rd.typ=enumdef) then
           begin
-            if allowenumop(nodetype) then
+            if allowenumop(nodetype) or (nf_internal in flags) then
               inserttypeconv(right,left.resultdef)
             else
               CGMessage3(type_e_operator_not_supported_for_types,node2opstr(nodetype),ld.typename,rd.typename);

+ 4 - 1
compiler/ncal.pas

@@ -1702,7 +1702,10 @@ implementation
                       typecheckpass(temp);
                       if (temp.nodetype <> ordconstn) or
                          (tordconstnode(temp).value <> 0) then
-                        hightree := caddnode.create(subn,hightree,temp)
+                        begin
+                          hightree:=caddnode.create(subn,hightree,temp);
+                          include(hightree.flags,nf_internal);
+                        end
                       else
                         temp.free;
                     end;

+ 25 - 0
tests/webtbs/tw27256.pp

@@ -0,0 +1,25 @@
+program Test;
+
+type
+  FullType = (Unknown,Stiletto,Vanguard);
+  SubType = Stiletto..Vanguard;
+
+const
+  full_choices: array[FullType] of String = ('U','S','V');
+  sub_choices: array[SubType] of String = ('S', 'V');
+
+var
+  x : longint;
+
+procedure abc(choices: array of String);
+begin
+  inc(x,high(choices));
+end;
+
+begin
+  abc(full_choices);
+  abc(sub_choices);
+  if x<>3 then
+    halt(1);
+  writeln('ok');
+end.