From 4befb415d7ee63d2b0ecdc2384310dc4b3ccc90a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Tue, 11 Jul 2017 15:41:20 -0400 Subject: Mention which -Werror promoted a warning to an error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously -Werror or -Werror=flag printed warnings as usual and then printed these two lines: : error: Failing due to -Werror. This is not ideal: first, it's not clear which flag made one of the warnings an error. Second, warning messages are not modified in any way, so there's no way to know which warnings caused this error. With this patch we (1) promote warning messages to error messages if a relevant -Werror is enabled (2) mention which -Werror is used during this promotion. Previously: [1 of 1] Compiling Main ( test.hs, test.o ) test.hs:9:10: warning: [-Wincomplete-patterns] Pattern match(es) are non-exhaustive In a case alternative: Patterns not matched: (C2 _) | 9 | sInt s = case s of | ^^^^^^^^^... test.hs:12:14: warning: [-Wmissing-fields] • Fields of ‘Rec’ not initialised: f2 • In the first argument of ‘print’, namely ‘Rec {f1 = 1}’ In the expression: print Rec {f1 = 1} In an equation for ‘main’: main = print Rec {f1 = 1} | 12 | main = print Rec{ f1 = 1 } | ^^^^^^^^^^^^^ : error: Failing due to -Werror. Now: [1 of 1] Compiling Main ( test.hs, test.o ) test.hs:9:10: error: [-Wincomplete-patterns, -Werror=incomplete-patterns] Pattern match(es) are non-exhaustive In a case alternative: Patterns not matched: (C2 _) | 9 | sInt s = case s of | ^^^^^^^^^... test.hs:12:14: error: [-Wmissing-fields, -Werror=missing-fields] • Fields of ‘Rec’ not initialised: f2 • In the first argument of ‘print’, namely ‘Rec {f1 = 1}’ In the expression: print Rec {f1 = 1} In an equation for ‘main’: main = print Rec {f1 = 1} | 12 | main = print Rec{ f1 = 1 } | ^^^^^^^^^^^^^ Test Plan: - Update old tests, add new tests if there aren't any relevant tests Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3709 --- testsuite/tests/driver/werror.stderr | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'testsuite/tests/driver/werror.stderr') diff --git a/testsuite/tests/driver/werror.stderr b/testsuite/tests/driver/werror.stderr index ccbeb393cd..2d9fd5324c 100644 --- a/testsuite/tests/driver/werror.stderr +++ b/testsuite/tests/driver/werror.stderr @@ -1,31 +1,28 @@ -werror.hs:6:1: warning: [-Wmissing-signatures (in -Wall)] +werror.hs:6:1: error: [-Wmissing-signatures (in -Wall), -Werror=missing-signatures] Top-level binding with no type signature: main :: IO () -werror.hs:7:13: warning: [-Wname-shadowing (in -Wall)] +werror.hs:7:13: error: [-Wname-shadowing (in -Wall), -Werror=name-shadowing] This binding for ‘main’ shadows the existing binding defined at werror.hs:6:1 -werror.hs:7:13: warning: [-Wunused-local-binds (in -Wextra, -Wunused-binds)] +werror.hs:7:13: error: [-Wunused-local-binds (in -Wextra, -Wunused-binds), -Werror=unused-local-binds] Defined but not used: ‘main’ -werror.hs:8:1: warning: [-Wtabs (in -Wdefault)] +werror.hs:8:1: error: [-Wtabs (in -Wdefault), -Werror=tabs] Tab character found here. Please use spaces instead. -werror.hs:10:1: warning: [-Wunused-top-binds (in -Wextra, -Wunused-binds)] +werror.hs:10:1: error: [-Wunused-top-binds (in -Wextra, -Wunused-binds), -Werror=unused-top-binds] Defined but not used: ‘f’ -werror.hs:10:1: warning: [-Wmissing-signatures (in -Wall)] +werror.hs:10:1: error: [-Wmissing-signatures (in -Wall), -Werror=missing-signatures] Top-level binding with no type signature: f :: [a1] -> [a2] -werror.hs:10:1: warning: [-Wincomplete-patterns (in -Wextra)] +werror.hs:10:1: error: [-Wincomplete-patterns (in -Wextra), -Werror=incomplete-patterns] Pattern match(es) are non-exhaustive In an equation for ‘f’: Patterns not matched: (_:_) -werror.hs:11:1: warning: [-Woverlapping-patterns (in -Wdefault)] +werror.hs:11:1: error: [-Woverlapping-patterns (in -Wdefault), -Werror=overlapping-patterns] Pattern match is redundant In an equation for ‘f’: f [] = ... - -: error: -Failing due to -Werror. -- cgit v1.2.1