Browse Source

* check for allowed floatdef operations

git-svn-id: trunk@1455 -
peter 20 years ago
parent
commit
4c73e86058
3 changed files with 27 additions and 3 deletions
  1. 1 0
      .gitattributes
  2. 2 3
      compiler/nadd.pas
  3. 24 0
      tests/webtbf/tw4445.pp

+ 1 - 0
.gitattributes

@@ -5641,6 +5641,7 @@ tests/webtbf/tw4153.pp svneol=native#text/plain
 tests/webtbf/tw4227.pp svneol=native#text/plain
 tests/webtbf/tw4227.pp svneol=native#text/plain
 tests/webtbf/tw4244.pp svneol=native#text/plain
 tests/webtbf/tw4244.pp svneol=native#text/plain
 tests/webtbf/tw4256.pp svneol=native#text/plain
 tests/webtbf/tw4256.pp svneol=native#text/plain
+tests/webtbf/tw4445.pp svneol=native#text/plain
 tests/webtbf/uw0744.pp svneol=native#text/plain
 tests/webtbf/uw0744.pp svneol=native#text/plain
 tests/webtbf/uw0840a.pp svneol=native#text/plain
 tests/webtbf/uw0840a.pp svneol=native#text/plain
 tests/webtbf/uw0840b.pp svneol=native#text/plain
 tests/webtbf/uw0840b.pp svneol=native#text/plain

+ 2 - 3
compiler/nadd.pas

@@ -1034,7 +1034,8 @@ implementation
          { if both are floatdefs, conversion is already done before constant folding }
          { if both are floatdefs, conversion is already done before constant folding }
          else if (ld.deftype=floatdef) then
          else if (ld.deftype=floatdef) then
            begin
            begin
-             { already converted }
+             if not(nodetype in [addn,subn,muln,slashn,equaln,unequaln,ltn,lten,gtn,gten]) then
+               CGMessage3(type_e_operator_not_supported_for_types,node2opstr(nodetype),ld.typename,rd.typename);
            end
            end
 
 
          { left side a setdef, must be before string processing,
          { left side a setdef, must be before string processing,
@@ -1803,8 +1804,6 @@ implementation
     function taddnode.first_addfloat : tnode;
     function taddnode.first_addfloat : tnode;
       var
       var
         procname: string[31];
         procname: string[31];
-        temp: tnode;
-        power: longint;
         { do we need to reverse the result ? }
         { do we need to reverse the result ? }
         notnode : boolean;
         notnode : boolean;
       begin
       begin

+ 24 - 0
tests/webtbf/tw4445.pp

@@ -0,0 +1,24 @@
+{ %fail }
+
+{ Source provided for Free Pascal Bug Report 4445 }
+{ Submitted by "lito steel" on  2005-10-17 }
+{ e-mail: [email protected] }
+{ those are the definitions }
+const
+  StackMax = 10;
+var
+       Stack:array[1..StackMax] of double;
+       StackTop: integer = 0;
+
+{in this procedure the compiler complains}
+procedure aAND;
+var a: double;
+begin
+  a := Stack[StackTop];
+  dec(StackTop);
+  Stack[StackTop] := Stack[StackTop] and a;
+end;
+
+begin
+  aand;
+end.