Browse Source

* don't allow logical operators on char, resolves #8780

git-svn-id: trunk@7181 -
florian 18 years ago
parent
commit
01de46a0f4
5 changed files with 25 additions and 1 deletions
  1. 3 0
      .gitattributes
  2. 7 1
      compiler/nadd.pas
  3. 5 0
      tests/webtbf/tw8780a.pp
  4. 5 0
      tests/webtbf/tw8780b.pp
  5. 5 0
      tests/webtbf/tw8780c.pp

+ 3 - 0
.gitattributes

@@ -7279,6 +7279,9 @@ tests/webtbf/tw8451.pp svneol=native#text/plain
 tests/webtbf/tw8528.pp svneol=native#text/plain
 tests/webtbf/tw8528.pp svneol=native#text/plain
 tests/webtbf/tw8583.pp svneol=native#text/plain
 tests/webtbf/tw8583.pp svneol=native#text/plain
 tests/webtbf/tw8588.pp svneol=native#text/plain
 tests/webtbf/tw8588.pp svneol=native#text/plain
+tests/webtbf/tw8780a.pp svneol=native#text/plain
+tests/webtbf/tw8780b.pp svneol=native#text/plain
+tests/webtbf/tw8780c.pp svneol=native#text/plain
 tests/webtbf/tw8781.pp svneol=native#text/plain
 tests/webtbf/tw8781.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

+ 7 - 1
compiler/nadd.pas

@@ -963,7 +963,13 @@ implementation
                        result := hp;
                        result := hp;
                        exit;
                        exit;
 {$endif addstringopt}
 {$endif addstringopt}
-                     end;
+                     end
+                  end
+                else if not(nodetype in [ltn,lten,gtn,gten,unequaln,equaln]) then
+                  begin
+                    CGMessage3(type_e_operator_not_supported_for_types,node2opstr(nodetype),ld.typename,rd.typename);
+                    result:=cnothingnode.create;
+                    exit;
                   end;
                   end;
                end
                end
              { There is a widechar? }
              { There is a widechar? }

+ 5 - 0
tests/webtbf/tw8780a.pp

@@ -0,0 +1,5 @@
+{ %fail }
+var c,c1,c2 : char;
+begin
+  c:=c1 or c2; // no error
+end.

+ 5 - 0
tests/webtbf/tw8780b.pp

@@ -0,0 +1,5 @@
+{ %fail }
+var c,c1,c2 : char;
+begin
+  c:='a' or 'b'; // Error: Operation "or" not supported for types "Char" and "Char"
+end.

+ 5 - 0
tests/webtbf/tw8780c.pp

@@ -0,0 +1,5 @@
+{ %fail }
+var c,c1,c2 : char;
+begin
+  c:=#1 or #2; // Error: Operation "or" not supported for types "Char" and "Char"
+end.