From 393afa6c0d306a33e3001e2641ae91a96ca947d0 Mon Sep 17 00:00:00 2001 From: Sebastian Graf Date: Fri, 13 Sep 2024 11:08:59 +0200 Subject: [PATCH] Emit a warning when -g was not passed (#268) Fixes #268. --- src/Main.lhs | 7 ++++++- tests/Makefile | 8 ++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Main.lhs b/src/Main.lhs index 93aa7207..36eb3a04 100644 --- a/src/Main.lhs +++ b/src/Main.lhs @@ -25,7 +25,7 @@ Path settings auto-generated by Cabal: > import Happy.Tabular.Info (genInfoFile) > import System.Console.GetOpt -> import Control.Monad ( liftM, when ) +> import Control.Monad ( liftM, when, unless ) > import System.Environment > import System.Exit (exitWith, ExitCode(..)) > import Data.Char @@ -62,6 +62,11 @@ Read and parse the CLI arguments. > where > runParserGen cli fl_name = do +If no -g flag has been passed, show a warning. + +> unless (OptGhcTarget `elem` cli) $ +> hPutStrLn stderr "Warning: With happy 2.0, the --ghc flag has become non-optional. To suppress this warning, pass the --ghc flag." + Open the file. > fl <- readFile fl_name diff --git a/tests/Makefile b/tests/Makefile index d61abfb6..17765d7d 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -44,16 +44,16 @@ ERROR_TESTS = error001.y # NOTE: `cabal` will set the `happy_datadir` env-var accordingly before invoking the test-suite #TEST_HAPPY_OPTS = --strict --template=.. -TEST_HAPPY_OPTS = --strict +TEST_HAPPY_OPTS = --strict -g %.n.hs : %.y $(HAPPY) $(TEST_HAPPY_OPTS) $< -o $@ %.n.hs : %.ly - $(HAPPY) $(TEST_HAPPY_OPTS) -c $< -o $@ + $(HAPPY) $(TEST_HAPPY_OPTS) $< -o $@ %.c.hs : %.y - $(HAPPY) $(TEST_HAPPY_OPTS) $< -o $@ + $(HAPPY) $(TEST_HAPPY_OPTS) -c $< -o $@ %.c.hs : %.ly $(HAPPY) $(TEST_HAPPY_OPTS) -c $< -o $@ @@ -80,7 +80,7 @@ path.run : # simply a test to output the path of the built happy executable, use check.%.y : %.y @echo "--> Checking $<..." - $(HAPPY) $(TEST_HAPPY_OPTS) $< 1>$*.run.stdout 2>$*.run.stderr || true + $(HAPPY) $(TEST_HAPPY_OPTS) -g $< 1>$*.run.stdout 2>$*.run.stderr || true sed -i '/^Up to date$$/d' $*.run.stdout $*.run.stderr @diff -u --ignore-all-space $*.stdout $*.run.stdout @diff -u --ignore-all-space $*.stderr $*.run.stderr