[GHC] #12752: GHC should be able to warn on usafe CPP usage
#12752: GHC should be able to warn on usafe CPP usage -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: feature | Status: new request | Priority: normal | Milestone: Component: Compiler | Version: 8.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Other Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- GCC has a warning `-Wundef` that catches unsafe CPP usage like: {{{#!c #if variable_does_not_exist // something #endif }}} The GCC man page says about `-Wundef`: {{{ -Wundef Warn if an undefined identifier is evaluated in an "#if" directive. }}} Following GCC's lead, GHC should have a similar warning flag to detect and warn about this problem in Haskell code that uses CPP. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12752> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12752: GHC should be able to warn on usafe CPP usage -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by erikd): * owner: => erikd -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12752#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12752: GHC should be able to warn on usafe CPP usage -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by erikd): I suspect this is just a matter of adding a GHC warning flag named something like `-Dcpp-undef` and then if that is set, passing `-Wundef` to the C pre-processor. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12752#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12752: GHC should be able to warn on unsafe CPP usage -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12752#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12752: GHC should be able to warn on unsafe CPP usage -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): phab:D2626 Wiki Page: | -------------------------------------+------------------------------------- Changes (by erikd): * differential: => phab:D2626 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12752#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12752: GHC should be able to warn on unsafe CPP usage -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): phab:D2626 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Ben Gamari <ben@…>): In [changeset:"3cb32d8b0b51c548ab424139c66cce6b37a2ab1b/ghc" 3cb32d8/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="3cb32d8b0b51c548ab424139c66cce6b37a2ab1b" Add -Wcpp-undef warning flag When enabled, this new warning flag passes `-Wundef` to the C pre-processor which causes the pre-processor to warn on uses of the `#if` directive on undefined identifiers. It is not currently enabled in any of the standard warning groups. Test Plan: Make sure the two tests pass on all major platforms. Reviewers: hvr, carter, Phyx, bgamari, austin Reviewed By: Phyx Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2626 GHC Trac Issues: #12752 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12752#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12752: GHC should be able to warn on unsafe CPP usage -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: feature request | Status: closed Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): phab:D2626 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => closed * resolution: => fixed * milestone: => 8.2.1 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12752#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12752: GHC should be able to warn on unsafe CPP usage -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: feature request | Status: closed Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 8.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): phab:D2626 Wiki Page: | -------------------------------------+------------------------------------- Comment (by rwbarton): Well okay, but you could also just use `-optP -Wundef` since forever. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12752#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC