summaryrefslogtreecommitdiff
path: root/tests/tbf
diff options
context:
space:
mode:
authorpierre <pierre@3ad0048d-3df7-0310-abae-a5850022a9f2>2018-12-11 08:47:59 +0000
committerpierre <pierre@3ad0048d-3df7-0310-abae-a5850022a9f2>2018-12-11 08:47:59 +0000
commitd574f445a2b6c97e54711999623de99ae741eb65 (patch)
treea67ff163a0ea3aecfc54ae574403d9b454624408 /tests/tbf
parentc3555335943d8c0f2ae5a7ea28e9647e7218e51a (diff)
downloadfpc-d574f445a2b6c97e54711999623de99ae741eb65.tar.gz
Modify tbs/tb0588.pp to check that a warning is issued about non-initialized return value, moved to tbf directory
git-svn-id: https://svn.freepascal.org/svn/fpc/trunk@40521 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'tests/tbf')
-rw-r--r--tests/tbf/tb0588.pp32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/tbf/tb0588.pp b/tests/tbf/tb0588.pp
new file mode 100644
index 0000000000..48927d702f
--- /dev/null
+++ b/tests/tbf/tb0588.pp
@@ -0,0 +1,32 @@
+{ %FAIL }
+{ %opt=-O4 -Sew }
+
+{ This code can generate trouble because
+ uninitialized retrun value in f method
+ can have a pattern that generates a
+ floating point exception later.
+
+ As core decided not to generate an error in such cases,
+ this test was modified to al least test that a warning
+ is issued about non-initialized return value. }
+
+{$mode objfpc}
+uses
+ sysutils;
+type
+ tmyclass = class
+ function f : double;virtual;
+ end;
+
+function tmyclass.f : double;
+ begin
+ end;
+
+var
+ myclass : tmyclass;
+begin
+ myclass:=tmyclass.create;
+ writeln(myclass.f+myclass.f+myclass.f);
+ myclass.free;
+ writeln('ok');
+end.