From ccb01d61968cf1ba62d8b2347a0e67b2fd71690a Mon Sep 17 00:00:00 2001 From: florian Date: Mon, 12 Jan 2015 20:56:17 +0000 Subject: [PATCH] * allow subtraction/addition of internally generated nodes, resolves #27256 git-svn-id: trunk@29456 - --- .gitattributes | 1 + compiler/nadd.pas | 7 +++---- compiler/ncal.pas | 5 ++++- tests/webtbs/tw27256.pp | 25 +++++++++++++++++++++++++ 4 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 tests/webtbs/tw27256.pp diff --git a/.gitattributes b/.gitattributes index d2145cceb8..d2f8892247 100644 --- a/.gitattributes +++ b/.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 diff --git a/compiler/nadd.pas b/compiler/nadd.pas index 9424c4e82b..ab89377400 100644 --- a/compiler/nadd.pas +++ b/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); diff --git a/compiler/ncal.pas b/compiler/ncal.pas index 57ff1b5d3d..fbaed15ebe 100644 --- a/compiler/ncal.pas +++ b/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; diff --git a/tests/webtbs/tw27256.pp b/tests/webtbs/tw27256.pp new file mode 100644 index 0000000000..bd7752f16d --- /dev/null +++ b/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.