Commit 0ebc8dc3 authored by David Feuer's avatar David Feuer Committed by David Feuer

Add a test for #14140

This issue seems to have been fixed by
193664d4 (Re-engineer caseRules
to add tagToEnum/dataToTag) but I don't think anyone realized
that.

Reviewers: simonpj, austin, bgamari

Reviewed By: simonpj

Subscribers: rwbarton, thomie

GHC Trac Issues: #14140

Differential Revision: https://phabricator.haskell.org/D3934
parent fe04f378
......@@ -230,3 +230,10 @@ T11272:
.PHONY: T12600
T12600:
'$(TEST_HC)' $(TEST_HC_OPTS) -c -O -ddump-prep -dsuppress-all -dsuppress-uniques -dno-suppress-type-signatures -dppr-cols=200 T12600.hs | grep "wfoo" | head -n 1
# We don't expect to case match on any literal numbers other than
# 0 or 1. See T14140.hs for an explanation.
T14140:
$(RM) -f T14140.o T14140.hi
-'$(TEST_HC)' $(TEST_HC_OPTS) -O -c -ddump-simpl T14140.hs | grep '[2-9]# *->'
# Expecting no output from the grep, hence "-"
-- We don't want to see a case match on the result
-- of dataToTag#. We check that by looking for case
-- matches on any literal other than 0# or 1#. We
-- only really expect to see 1# here (and not the tag
-- for OtherOS), but just in case GHC decides to get
-- clever with its knowledge of the possible results
-- of (==#), we also permit 0#.
{-# LANGUAGE MagicHash, BangPatterns #-}
module T14140 where
import GHC.Exts
data OS = Linux | Windows | OSX -- tier 1 desktop OSs
| FreeBSD | OpenBSD | NetBSD -- other free Unix OSs
| DragonFly
| Solaris | AIX | HPUX | IRIX -- ageing Unix OSs
| HaLVM -- bare metal / VMs / hypervisors
| Hurd -- GNU's microkernel
| IOS | Android -- mobile OSs
| Ghcjs
| OtherOS String
-- This is similar to the derived Eq instance. We write it
-- out manually to prevent future deriving changes from
-- changing the test.
instance Eq OS where
OtherOS x == OtherOS y = x == y
(!x) == (!y) = case dataToTag# x ==# dataToTag# y of
1# -> True
_ -> False
......@@ -274,3 +274,8 @@ test('T13708', normal, compile, [''])
test('T14137', [ check_errmsg(r'thunk') ], compile, ['-dsuppress-uniques -ddump-simpl'])
# bar and foo should CSEd here, so check for that in the Core
test('T14186', [ only_ways(['optasm']), check_errmsg(r'bar = foo') ], compile, ['-ddump-simpl'])
test('T14140',
normal,
run_command,
['$MAKE -s --no-print-directory T14140'])
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment