diff options
Diffstat (limited to 'testsuite/tests/codeGen/should_run')
-rw-r--r-- | testsuite/tests/codeGen/should_run/CgStaticPointers.hs | 31 | ||||
-rw-r--r-- | testsuite/tests/codeGen/should_run/CgStaticPointers.stdout | 2 | ||||
-rw-r--r-- | testsuite/tests/codeGen/should_run/all.T | 3 |
3 files changed, 36 insertions, 0 deletions
diff --git a/testsuite/tests/codeGen/should_run/CgStaticPointers.hs b/testsuite/tests/codeGen/should_run/CgStaticPointers.hs new file mode 100644 index 0000000000..bc11f4b076 --- /dev/null +++ b/testsuite/tests/codeGen/should_run/CgStaticPointers.hs @@ -0,0 +1,31 @@ +{-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE StaticPointers #-} + +-- |A test to load symbols produced by the static form. +-- +-- First we have this program load itself using the GHC API. +-- Then we look for the symbols that the static form should have +-- exposed and use the values found at the symbol addresses. +-- +module Main(main) where + +import Data.Typeable +import GHC.StaticPtr + +main :: IO () +main = do + -- For some reason, removing the type signature below causes @g@ to appear + -- in the desugarer with a coercion like: + -- main@main:Main.g{v r20J} |> (Sub cobox_a36d{v}[lid]) + print $ deRefStaticPtr (static g :: StaticPtr String) + -- For some reason, removing the type signature below causes an assertion + -- failure in the compiler: + -- + -- ASSERT failed! file compiler/typecheck/TcType.lhs line 645 + print $ deRefStaticPtr (static t_field :: StaticPtr (T Char -> Char)) $ T 'b' + +g :: String +g = "found" + +data T a = T { t_field :: a } + deriving Typeable diff --git a/testsuite/tests/codeGen/should_run/CgStaticPointers.stdout b/testsuite/tests/codeGen/should_run/CgStaticPointers.stdout new file mode 100644 index 0000000000..f867935850 --- /dev/null +++ b/testsuite/tests/codeGen/should_run/CgStaticPointers.stdout @@ -0,0 +1,2 @@ +"found" +'b' diff --git a/testsuite/tests/codeGen/should_run/all.T b/testsuite/tests/codeGen/should_run/all.T index 03106d4791..ae6874900e 100644 --- a/testsuite/tests/codeGen/should_run/all.T +++ b/testsuite/tests/codeGen/should_run/all.T @@ -114,6 +114,9 @@ test('T8103', only_ways(['normal']), compile_and_run, ['']) test('T7953', reqlib('random'), compile_and_run, ['']) test('T8256', reqlib('vector'), compile_and_run, ['']) test('T6084',normal, compile_and_run, ['-O2']) +test('CgStaticPointers', + [ when(compiler_lt('ghc', '7.9'), skip) ], + compile_and_run, ['']) test('StaticArraySize', normal, compile_and_run, ['-O2']) test('StaticByteArraySize', normal, compile_and_run, ['-O2']) test('CopySmallArray', normal, compile_and_run, ['']) |