Browse Source

* properly handle pointer consts in texprvalue.destroy, resolves #41487

florian 1 month ago
parent
commit
3258cf1bba
2 changed files with 46 additions and 0 deletions
  1. 1 0
      compiler/scanner.pas
  2. 45 0
      tests/webtbs/tw41487.pp

+ 1 - 0
compiler/scanner.pas

@@ -1587,6 +1587,7 @@ type
           dispose(pnormalset(value.valueptr));
           dispose(pnormalset(value.valueptr));
         constguid :
         constguid :
           dispose(pguid(value.valueptr));
           dispose(pguid(value.valueptr));
+        constpointer,
         constord,
         constord,
         { error values }
         { error values }
         constnone:
         constnone:

+ 45 - 0
tests/webtbs/tw41487.pp

@@ -0,0 +1,45 @@
+program const_internal_error;
+
+const
+  ACONSTANT = 3;
+
+  b         = 5;
+
+  { can do this: }
+
+  {$if ACONSTANT <> b}
+    {$MESSAGE 'ACONSTANT is not equal to b'}
+  {$endif}
+
+
+type
+  PRECORD = ^TRECORD;
+  TRECORD = record
+    FirstField  : integer;
+    SecondField : DWORD;
+  end;
+
+
+const
+  { can define constants that represent the field offsets                     }
+
+  RECORD_FIRSTFIELD_OFFSET  = SizeInt(@PRECORD(nil)^.FirstField);
+  RECORD_SECONDFIELD_OFFSET = SizeInt(@PRECORD(nil)^.SecondField);
+
+  { CAN NOT do this: }
+
+  {$if RECORD_FIRSTFIELD_OFFSET <> 5}
+    {$MESSAGE 'RECORD_FIRSTFIELD_OFFSET is not equal to 5'}
+  {$endif}
+
+  { NOR this:        }
+
+  {$if RECORD_FIRSTFIELD_OFFSET <> RECORD_SECONDFIELD_OFFSET}
+    {$MESSAGE 'RECORD_FIRSTFIELD_OFFSET is not equal to RECORD_SECONDFIELD_OFFSET'}
+  {$endif}
+
+
+begin
+
+  readln;
+end.