浏览代码

* instead of blindly consuming whatever comes next trigger an explicit error if the parsed expression does not match for "INDEX ordexpr" or "NAME strexpr"
+ added tests

git-svn-id: trunk@47995 -

svenbarth 4 年之前
父节点
当前提交
d854d18bd9
共有 4 个文件被更改,包括 20 次插入2 次删除
  1. 2 0
      .gitattributes
  2. 2 2
      compiler/pexports.pas
  3. 8 0
      tests/webtbf/tw38289a.pp
  4. 8 0
      tests/webtbf/tw38289b.pp

+ 2 - 0
.gitattributes

@@ -16697,6 +16697,8 @@ tests/webtbf/tw37476.pp svneol=native#text/pascal
 tests/webtbf/tw37763.pp svneol=native#text/pascal
 tests/webtbf/tw37763.pp svneol=native#text/pascal
 tests/webtbf/tw3790.pp svneol=native#text/plain
 tests/webtbf/tw3790.pp svneol=native#text/plain
 tests/webtbf/tw3812.pp svneol=native#text/plain
 tests/webtbf/tw3812.pp svneol=native#text/plain
+tests/webtbf/tw38289a.pp svneol=native#text/pascal
+tests/webtbf/tw38289b.pp svneol=native#text/pascal
 tests/webtbf/tw3930a.pp svneol=native#text/plain
 tests/webtbf/tw3930a.pp svneol=native#text/plain
 tests/webtbf/tw3931b.pp svneol=native#text/plain
 tests/webtbf/tw3931b.pp svneol=native#text/plain
 tests/webtbf/tw3969.pp svneol=native#text/plain
 tests/webtbf/tw3969.pp svneol=native#text/plain

+ 2 - 2
compiler/pexports.pas

@@ -149,7 +149,7 @@ implementation
                        else
                        else
                         begin
                         begin
                           index:=0;
                           index:=0;
-                          consume(_INTCONST);
+                          message(type_e_ordinal_expr_expected);
                         end;
                         end;
                        include(options,eo_index);
                        include(options,eo_index);
                        pt.free;
                        pt.free;
@@ -166,7 +166,7 @@ implementation
                        else if is_constcharnode(pt) then
                        else if is_constcharnode(pt) then
                          hpname:=chr(tordconstnode(pt).value.svalue and $ff)
                          hpname:=chr(tordconstnode(pt).value.svalue and $ff)
                        else
                        else
-                         consume(_CSTRING);
+                         message(type_e_string_expr_expected);
                        include(options,eo_name);
                        include(options,eo_name);
                        pt.free;
                        pt.free;
                        DefString:=hpname+'='+InternalProcName;
                        DefString:=hpname+'='+InternalProcName;

+ 8 - 0
tests/webtbf/tw38289a.pp

@@ -0,0 +1,8 @@
+{ %FAIL }
+
+library tw38289a;
+procedure Test; begin end;
+exports
+  Test index 3 'abc';
+  //------------^^^
+end.

+ 8 - 0
tests/webtbf/tw38289b.pp

@@ -0,0 +1,8 @@
+{ %FAIL }
+
+library tw38289b;
+procedure Test; begin end;
+exports
+  Test index 'abc' 3;
+  //------------^^^
+end.