[commit: ghc] master: Fixes #12504: Double-escape paths used to build call to hsc_line (2ee1db6)
git at git.haskell.org
git at git.haskell.org
Wed Aug 31 17:19:18 UTC 2016
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/2ee1db60ab29258fa9f8ab820f778bd0bb7f87a4/ghc
>---------------------------------------------------------------
commit 2ee1db60ab29258fa9f8ab820f778bd0bb7f87a4
Author: Richard Cook <rcook at rcook.org>
Date: Tue Aug 30 17:00:36 2016 -0400
Fixes #12504: Double-escape paths used to build call to hsc_line
In outHsLine, paths passed to construct invocations of hsc_line must be
escaped twice in order to generate a properly escaped string literal
that will end up in the eventual LINE pragma emitted by this code. This
is especially important on Windows paths, where backslashes would
otherwise be treated as C escape sequences and result in the incorrect
Windows paths.
Adds test case to verify that hsc2hs properly escapes file paths in LINE
pragmas
Updates the hsc2hs submodule.
See https://ghc.haskell.org/trac/ghc/ticket/12504
Reviewers: erikd, hvr, austin, bgamari, Phyx
Reviewed By: erikd, Phyx
Subscribers: thomie, Phyx, mpickering
Differential Revision: https://phabricator.haskell.org/D2478
GHC Trac Issues: #12504
>---------------------------------------------------------------
2ee1db60ab29258fa9f8ab820f778bd0bb7f87a4
testsuite/.gitignore | 1 +
testsuite/tests/hsc2hs/Makefile | 11 +++++++++++
testsuite/tests/hsc2hs/T12504.stdout | 2 ++
.../{driver/T11429a.hs => hsc2hs/T12504/path/to/T12504.hsc} | 3 +++
testsuite/tests/hsc2hs/all.T | 6 ++++++
utils/hsc2hs | 2 +-
6 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/testsuite/.gitignore b/testsuite/.gitignore
index 87e3558..5e3f1c2 100644
--- a/testsuite/.gitignore
+++ b/testsuite/.gitignore
@@ -790,6 +790,7 @@ mk/ghcconfig*_test___spaces_ghc*.exe.mk
/tests/ghci/scripts/ghci027.hs
/tests/ghci/should_run/3171.err
/tests/hsc2hs/3837.hs
+/tests/hsc2hs/T12504/path/to/T12504.hs
/tests/hsc2hs/T3837.hs
/tests/hsc2hs/hsc2hs001.hs
/tests/hsc2hs/hsc2hs002.hs
diff --git a/testsuite/tests/hsc2hs/Makefile b/testsuite/tests/hsc2hs/Makefile
index 54fa5ad..9b3ee98 100644
--- a/testsuite/tests/hsc2hs/Makefile
+++ b/testsuite/tests/hsc2hs/Makefile
@@ -40,3 +40,14 @@ T10272:
'$(HSC2HS)' --cross-compile $@.hsc
'$(TEST_HC)' $(TEST_HC_OPTS) -v0 --make $@
./$@
+
+.PHONY: T12504
+T12504:
+ '$(HSC2HS)' T12504/path/to/$@.hsc
+ifeq "$(WINDOWS)" "YES"
+ grep '{-# LINE 1 \"T12504\\\\path\\\\to\\\\$@\.hsc\" #-}' T12504/path/to/$@.hs
+ grep '{-# LINE 2 \"T12504\\\\path\\\\to\\\\$@\.hsc\" #-}' T12504/path/to/$@.hs
+else
+ grep '{-# LINE 1 \"T12504/path/to/$@\.hsc\" #-}' T12504/path/to/$@.hs
+ grep '{-# LINE 2 \"T12504/path/to/$@\.hsc\" #-}' T12504/path/to/$@.hs
+endif
diff --git a/testsuite/tests/hsc2hs/T12504.stdout b/testsuite/tests/hsc2hs/T12504.stdout
new file mode 100644
index 0000000..c1c05d0
--- /dev/null
+++ b/testsuite/tests/hsc2hs/T12504.stdout
@@ -0,0 +1,2 @@
+{-# LINE 1 "T12504/path/to/T12504.hsc" #-}
+{-# LINE 2 "T12504/path/to/T12504.hsc" #-}
diff --git a/testsuite/tests/driver/T11429a.hs b/testsuite/tests/hsc2hs/T12504/path/to/T12504.hsc
similarity index 61%
copy from testsuite/tests/driver/T11429a.hs
copy to testsuite/tests/hsc2hs/T12504/path/to/T12504.hsc
index c81fb82..3d05ce0 100644
--- a/testsuite/tests/driver/T11429a.hs
+++ b/testsuite/tests/hsc2hs/T12504/path/to/T12504.hsc
@@ -1,2 +1,5 @@
+module Main (main) where
+
main :: IO ()
main = putStrLn "hello world"
+
diff --git a/testsuite/tests/hsc2hs/all.T b/testsuite/tests/hsc2hs/all.T
index d4fc69d..3f910db 100644
--- a/testsuite/tests/hsc2hs/all.T
+++ b/testsuite/tests/hsc2hs/all.T
@@ -35,3 +35,9 @@ test('T10272',
[extra_clean(['T10272.hs', 'T10272_hsc_make.c'])],
run_command,
['$MAKE -s --no-print-directory T10272'])
+
+test('T12504',
+ [extra_clean(['T12504/path/to/T12504.hs']),
+ extra_files(['T12504'])],
+ run_command,
+ ['$MAKE -s --no-print-directory T12504'])
diff --git a/utils/hsc2hs b/utils/hsc2hs
index 5119aeb..f5ae016 160000
--- a/utils/hsc2hs
+++ b/utils/hsc2hs
@@ -1 +1 @@
-Subproject commit 5119aebacaca75d983b4d7db32a6305b7f8651dd
+Subproject commit f5ae016e5a69ebf42d612805e51afd9227df9389
More information about the ghc-commits
mailing list