[commit: ghc] master: Implement recompilation checking for -fignore-asserts (1a9c3c4)

git at git.haskell.org git at git.haskell.org
Mon Jul 3 22:58:43 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/1a9c3c44ef82803766a8db91a619393c43195ad3/ghc

>---------------------------------------------------------------

commit 1a9c3c44ef82803766a8db91a619393c43195ad3
Author: Ömer Sinan Ağacan <omeragacan at gmail.com>
Date:   Mon Jul 3 16:53:31 2017 -0400

    Implement recompilation checking for -fignore-asserts
    
    Test Plan: Added a test which was previously failing
    
    Reviewers: austin, bgamari, simonpj
    
    Reviewed By: simonpj
    
    Subscribers: simonpj, rwbarton, thomie
    
    GHC Trac Issues: #13914
    
    Differential Revision: https://phabricator.haskell.org/D3698


>---------------------------------------------------------------

1a9c3c44ef82803766a8db91a619393c43195ad3
 compiler/iface/FlagChecker.hs               |  6 +++++-
 testsuite/tests/driver/T13914/Makefile      | 16 ++++++++++++++++
 testsuite/tests/driver/T13914/T13914.stdout | 16 ++++++++++++++++
 testsuite/tests/driver/T13914/all.T         |  4 ++++
 testsuite/tests/driver/T13914/main.hs       |  3 +++
 5 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/compiler/iface/FlagChecker.hs b/compiler/iface/FlagChecker.hs
index 2c0b6c4..fd0459d 100644
--- a/compiler/iface/FlagChecker.hs
+++ b/compiler/iface/FlagChecker.hs
@@ -61,8 +61,12 @@ fingerprintDynFlags dflags at DynFlags{..} this_mod nameio =
         -- hpcDir is output-only, so we should recompile if it changes
         hpc = if gopt Opt_Hpc dflags then Just hpcDir else Nothing
 
+        -- -fignore-asserts, which affects how `Control.Exception.assert` works
+        ignore_asserts = gopt Opt_IgnoreAsserts dflags
+
         -- Nesting just to avoid ever more Binary tuple instances
-        flags = (mainis, safeHs, lang, cpp, paths, (prof, opt, hpc))
+        flags = (mainis, safeHs, lang, cpp, paths,
+                 (prof, opt, hpc, ignore_asserts))
 
     in -- pprTrace "flags" (ppr flags) $
        computeFingerprint nameio flags
diff --git a/testsuite/tests/driver/T13914/Makefile b/testsuite/tests/driver/T13914/Makefile
new file mode 100644
index 0000000..764942c
--- /dev/null
+++ b/testsuite/tests/driver/T13914/Makefile
@@ -0,0 +1,16 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
+
+t13914:
+	echo "Without -fignore-asserts"
+	'$(TEST_HC)' $(TEST_HC_OPTS) main.hs
+	(./main 2>&1); true
+	sleep 1
+	echo "With -fignore-asserts"
+	'$(TEST_HC)' $(TEST_HC_OPTS) -fignore-asserts main.hs
+	./main 2>&1
+	sleep 1
+	echo "Without -fignore-asserts"
+	'$(TEST_HC)' $(TEST_HC_OPTS) main.hs
+	(./main 2>&1); true
diff --git a/testsuite/tests/driver/T13914/T13914.stdout b/testsuite/tests/driver/T13914/T13914.stdout
new file mode 100644
index 0000000..04d14aa
--- /dev/null
+++ b/testsuite/tests/driver/T13914/T13914.stdout
@@ -0,0 +1,16 @@
+Without -fignore-asserts
+[1 of 1] Compiling Main             ( main.hs, main.o )
+Linking main ...
+main: Assertion failed
+CallStack (from HasCallStack):
+  assert, called at main.hs:3:8 in main:Main
+With -fignore-asserts
+[1 of 1] Compiling Main             ( main.hs, main.o ) [flags changed]
+Linking main ...
+OK
+Without -fignore-asserts
+[1 of 1] Compiling Main             ( main.hs, main.o ) [flags changed]
+Linking main ...
+main: Assertion failed
+CallStack (from HasCallStack):
+  assert, called at main.hs:3:8 in main:Main
diff --git a/testsuite/tests/driver/T13914/all.T b/testsuite/tests/driver/T13914/all.T
new file mode 100644
index 0000000..2e6a952
--- /dev/null
+++ b/testsuite/tests/driver/T13914/all.T
@@ -0,0 +1,4 @@
+test('T13914',
+     [extra_files(['main.hs'])],
+     run_command,
+     ['$MAKE -s --no-print-directory t13914'])
diff --git a/testsuite/tests/driver/T13914/main.hs b/testsuite/tests/driver/T13914/main.hs
new file mode 100644
index 0000000..859f3e6
--- /dev/null
+++ b/testsuite/tests/driver/T13914/main.hs
@@ -0,0 +1,3 @@
+import Control.Exception (assert)
+
+main = assert False (putStrLn "OK")



More information about the ghc-commits mailing list