From 5086cf7e7236e2abd8d613e4871916f6c60cd28a Mon Sep 17 00:00:00 2001 From: florian Date: Fri, 8 Mar 2024 20:12:55 +0100 Subject: [PATCH] * set packenum and setalloc to defined values when changing mode, resolves #40056 --- compiler/scanner.pas | 13 ++++++++++--- tests/webtbs/tw40056.pp | 10 ++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 tests/webtbs/tw40056.pp diff --git a/compiler/scanner.pas b/compiler/scanner.pas index 4352d80a0c..9e024adbd0 100644 --- a/compiler/scanner.pas +++ b/compiler/scanner.pas @@ -628,10 +628,17 @@ implementation current_settings.setalloc:=1; end else if (m_mac in current_settings.modeswitches) then - { compatible with Metrowerks Pascal } - current_settings.packenum:=2 + begin + { compatible with Metrowerks Pascal } + current_settings.packenum:=2; + current_settings.setalloc:=default_settings.setalloc; + end else - current_settings.packenum:=4; + begin + current_settings.packenum:=default_settings.packenum; + current_settings.setalloc:=default_settings.setalloc; + end; + if changeinit then begin init_settings.packenum:=current_settings.packenum; diff --git a/tests/webtbs/tw40056.pp b/tests/webtbs/tw40056.pp new file mode 100644 index 0000000000..3573f099c3 --- /dev/null +++ b/tests/webtbs/tw40056.pp @@ -0,0 +1,10 @@ +{ %opt=-MDelphi } +program SetTest; +{$mode objfpc} +type + TEnum = (one, two); + TSet = set of TEnum; +begin + if SizeOf(TSet)<>4 then + halt(1); +end.