Browse Source

* fixed web bug #4724 (don't allow inc/dec(pointer,pointer)
* more accurate error postitions for inc/dec errors

git-svn-id: trunk@2502 -

Jonas Maebe 19 years ago
parent
commit
5007ae7197
3 changed files with 19 additions and 6 deletions
  1. 1 0
      .gitattributes
  2. 12 6
      compiler/ninl.pas
  3. 6 0
      tests/webtbf/tw4724.pp

+ 1 - 0
.gitattributes

@@ -5987,6 +5987,7 @@ tests/webtbf/tw4619b.pp svneol=native#text/plain
 tests/webtbf/tw4647.pp svneol=native#text/plain
 tests/webtbf/tw4651.pp svneol=native#text/plain
 tests/webtbf/tw4695.pp svneol=native#text/plain
+tests/webtbf/tw4724.pp svneol=native#text/plain
 tests/webtbf/tw4737.pp svneol=native#text/plain
 tests/webtbf/tw4757.pp svneol=native#text/plain
 tests/webtbf/tw4764.pp svneol=native#text/plain

+ 12 - 6
compiler/ninl.pas

@@ -1666,17 +1666,23 @@ implementation
                           { two paras ? }
                           if assigned(tcallparanode(left).right) then
                            begin
-                             set_varstate(tcallparanode(tcallparanode(left).right).left,vs_read,[vsf_must_be_valid]);
-                             inserttypeconv_internal(tcallparanode(tcallparanode(left).right).left,tcallparanode(left).left.resulttype);
-                             if assigned(tcallparanode(tcallparanode(left).right).right) then
-                               CGMessage(parser_e_illegal_expression);
+                             if is_integer(tcallparanode(left).right.resulttype.def) then
+                               begin
+                                 set_varstate(tcallparanode(tcallparanode(left).right).left,vs_read,[vsf_must_be_valid]);
+                                 inserttypeconv_internal(tcallparanode(tcallparanode(left).right).left,tcallparanode(left).left.resulttype);
+                                 if assigned(tcallparanode(tcallparanode(left).right).right) then
+                                   { should be handled in the parser (JM) }
+                                   internalerror(2006020901);
+                               end
+                             else
+                               CGMessagePos(tcallparanode(left).right.fileinfo,type_e_ordinal_expr_expected);
                            end;
                         end
                        else
-                        CGMessage(type_e_ordinal_expr_expected);
+                        CGMessagePos(left.fileinfo,type_e_ordinal_expr_expected);
                     end
                   else
-                    CGMessage(type_e_mismatch);
+                    CGMessagePos(fileinfo,type_e_mismatch);
                 end;
 
               in_read_x,

+ 6 - 0
tests/webtbf/tw4724.pp

@@ -0,0 +1,6 @@
+{ %fail }
+var
+  p1, p2: pointer;
+begin
+  dec(p1,p2);
+end.