diff --git a/.gitattributes b/.gitattributes index e83b5804fe..ffbac75ece 100644 --- a/.gitattributes +++ b/.gitattributes @@ -12603,6 +12603,9 @@ tests/webtbs/tw2159.pp svneol=native#text/plain tests/webtbs/tw21592.pp svneol=native#text/pascal tests/webtbs/tw21592b.pp svneol=native#text/pascal tests/webtbs/tw21593.pp svneol=native#text/pascal +tests/webtbs/tw21593a.pp svneol=native#text/pascal +tests/webtbs/tw21593b.pp svneol=native#text/pascal +tests/webtbs/tw21593c.pp svneol=native#text/pascal tests/webtbs/tw2163.pp svneol=native#text/plain tests/webtbs/tw21654.pp svneol=native#text/pascal tests/webtbs/tw21674.pp svneol=native#text/pascal diff --git a/compiler/pdecl.pas b/compiler/pdecl.pas index 3a2b0ade2b..8eee372a30 100644 --- a/compiler/pdecl.pas +++ b/compiler/pdecl.pas @@ -153,9 +153,27 @@ implementation else Message(parser_e_illegal_expression); end; + inlinen: + begin + { this situation only happens if a intrinsic is parsed that has a + generic type as its argument. As we don't know certain + information about the final type yet, we need to use safe + values (mostly 0) } + if not parse_generic then + Message(parser_e_illegal_expression); + case tinlinenode(p).inlinenumber of + in_sizeof_x, + in_bitsizeof_x: + begin + hp:=tconstsym.create_ord(orgname,constord,0,p.resultdef); + end; + { add other cases here if necessary } + else + Message(parser_e_illegal_expression); + end; + end; else - if not(parse_generic) then - Message(parser_e_illegal_expression); + Message(parser_e_illegal_expression); end; current_tokenpos:=storetokenpos; p.free; diff --git a/tests/webtbs/tw21593a.pp b/tests/webtbs/tw21593a.pp new file mode 100644 index 0000000000..7d95a9d943 --- /dev/null +++ b/tests/webtbs/tw21593a.pp @@ -0,0 +1,19 @@ +program tw21593a; + +{$MODE DELPHI} + +type + TWrapper = record + class procedure Test; static; + end; + +class procedure TWrapper.Test; +const + Size = SizeOf(T); { Error: Illegal expression } +begin + Writeln(Size); +end; + +begin + TWrapper.Test; +end. diff --git a/tests/webtbs/tw21593b.pp b/tests/webtbs/tw21593b.pp new file mode 100644 index 0000000000..35fd7e9932 --- /dev/null +++ b/tests/webtbs/tw21593b.pp @@ -0,0 +1,20 @@ +program tw21593b; + +{$MODE DELPHI} + +type + TWrapper = record + strict private + const Size = SizeOf(T); { Error: Illegal expression } + public + class procedure Test; static; + end; + +class procedure TWrapper.Test; +begin + Writeln(Size); +end; + +begin + TWrapper.Test; +end. diff --git a/tests/webtbs/tw21593c.pp b/tests/webtbs/tw21593c.pp new file mode 100644 index 0000000000..5f44f92856 --- /dev/null +++ b/tests/webtbs/tw21593c.pp @@ -0,0 +1,19 @@ +program tw21593c; + +{$MODE DELPHI} + +type + TWrapper = record + class procedure Test; static; + end; + +class procedure TWrapper.Test; +var + size: SizeInt = SizeOf(T); { Error: Illegal expression } +begin + Writeln(size); +end; + +begin + TWrapper.Test; +end.