From 52a4f5ab44a7d4c89189b9132a5560cb85d18714 Mon Sep 17 00:00:00 2001
From: Andreas Klebinger <klebinger.andreas@gmx.at>
Date: Wed, 12 Jan 2022 16:42:26 +0100
Subject: [PATCH] Add test for #20938.

---
 testsuite/tests/profiling/should_compile/T20938.hs | 10 ++++++++++
 testsuite/tests/profiling/should_compile/all.T     |  1 +
 testsuite/tests/profiling/should_fail/all.T        |  1 -
 3 files changed, 11 insertions(+), 1 deletion(-)
 create mode 100644 testsuite/tests/profiling/should_compile/T20938.hs

diff --git a/testsuite/tests/profiling/should_compile/T20938.hs b/testsuite/tests/profiling/should_compile/T20938.hs
new file mode 100644
index 000000000000..29370999236d
--- /dev/null
+++ b/testsuite/tests/profiling/should_compile/T20938.hs
@@ -0,0 +1,10 @@
+{-# language MagicHash #-}
+
+-- We can't put code ticks between things which are required to be saturated
+-- and their arguments.
+module T20938 where
+
+import GHC.Exts
+
+foo x = ({-# SCC foo #-} tagToEnum#) x :: Bool
+
diff --git a/testsuite/tests/profiling/should_compile/all.T b/testsuite/tests/profiling/should_compile/all.T
index a6a6d50c7c33..a19a2fc49aaa 100644
--- a/testsuite/tests/profiling/should_compile/all.T
+++ b/testsuite/tests/profiling/should_compile/all.T
@@ -10,3 +10,4 @@ test('T14931', [only_ways(['normal']), req_profiling, unless(have_dynamic(), ski
      makefile_test, ['T14931'])
 test('T15108', [only_ways(['normal']), req_profiling], compile, ['-O -prof -fprof-auto'])
 test('T19894', [only_ways(['normal']), req_profiling, extra_files(['T19894'])], multimod_compile, ['Main', '-v0 -O2 -prof -fprof-auto -iT19894'])
+test('T20938', [only_ways(['normal']), req_profiling, expect_broken(20938)], compile, ['-O -prof'])
diff --git a/testsuite/tests/profiling/should_fail/all.T b/testsuite/tests/profiling/should_fail/all.T
index 00a7a16025c5..fee845405028 100644
--- a/testsuite/tests/profiling/should_fail/all.T
+++ b/testsuite/tests/profiling/should_fail/all.T
@@ -1,4 +1,3 @@
 
 test('proffail001', normal, compile_fail, ['-prof -fprof-cafs'])
 test('T17916', normal, compile_fail, [''])
-
-- 
GitLab