[GHC] #314: #line pragmas not respected inside nested comments

GHC trac at galois.com
Thu Oct 19 12:00:56 EDT 2006


#314: #line pragmas not respected inside nested comments
-------------------------------+--------------------------------------------
 Reporter:  nobody             |          Owner:  simonmar
     Type:  bug                |         Status:  assigned
 Priority:  low                |      Milestone:  6.8     
Component:  Compiler (Parser)  |        Version:  6.4     
 Severity:  normal             |     Resolution:  None    
 Keywords:                     |     Difficulty:  Unknown 
 Testcase:  read032            |   Architecture:  Unknown 
       Os:  Unknown            |  
-------------------------------+--------------------------------------------
Changes (by igloo):

  * architecture:  => Unknown
  * difficulty:  => Unknown
  * milestone:  => 6.8
  * testcase:  => read032
  * os:  => Unknown

Old description:

> {{{
> If one tries to compile a .hs file, with the -cpp
> option and the file contains
> C-style comments (/* comment */), then the linenumbers
> GHC reports
> are wrong.
>
> Minimal file exhibiting the error:
>
> ---
> {-
> /*
>  * Copyright (c) 2005 Jesper Louis Andersen
> <jlouis at mongers.org>
>  *
>  * Permission to use, copy, modify, and distribute this
> software for any
>  * purpose with or without fee is hereby granted,
> provided that the above
>  * copyright notice and this permission notice appear
> in all copies.
>  *
>  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR
> DISCLAIMS ALL WARRANTIES
>  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
> WARRANTIES OF
>  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
> AUTHOR BE LIABLE FOR
>  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
> DAMAGES OR ANY DAMAGES
>  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
> PROFITS, WHETHER IN AN
>  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
> ACTION, ARISING OUT OF
>  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
> SOFTWARE.
>  */
> -}
>
> c = 3 * "string"
>
> main = putStrLn $ show c
> ----
>
> ; ghc -cpp tmp.hs
>
> tmp.hs:6:
>     No instance for (Num [Char])
>       arising from use of `*' at tmp.hs:6
>     In the definition of `c': c = 3 * "string"
>
> Which is clearly wrong, since ``c'' is not defined on
> line 6.
>
> Note I am not sure wether it is in the parser, or it is
> rather in compilation
> chain where cpp gets invoked one has to look for the
> error. I have filed
> it as a parser-bug nonetheless.
>
> Fix: cpp(1) seems to output comments in the style
> # xx "filename"
>
> where ``xx'' is a number stating the linenumber in the
> original file.
> Keeping track of this probably fixes the bug.
>
> CPP version: GNU CPP from GCC 3.3.5
> Operating System: OpenBSD 3.6-current (GENERIC) #1: Sun
> Feb 20 10:23:54 CET 2005
>
> Submitter: Jesper Louis Andersen <jlouis at mongers.org>
>
> }}}

New description:

 {{{
 If one tries to compile a .hs file, with the -cpp
 option and the file contains
 C-style comments (/* comment */), then the linenumbers
 GHC reports
 are wrong.

 Minimal file exhibiting the error:

 ---
 {-
 /*
  * Copyright (c) 2005 Jesper Louis Andersen
 <jlouis at mongers.org>
  *
  * Permission to use, copy, modify, and distribute this
 software for any
  * purpose with or without fee is hereby granted,
 provided that the above
  * copyright notice and this permission notice appear
 in all copies.
  *
  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR
 DISCLAIMS ALL WARRANTIES
  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
 WARRANTIES OF
  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
 AUTHOR BE LIABLE FOR
  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
 DAMAGES OR ANY DAMAGES
  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
 PROFITS, WHETHER IN AN
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
 ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 SOFTWARE.
  */
 -}

 c = 3 * "string"

 main = putStrLn $ show c
 ----

 ; ghc -cpp tmp.hs

 tmp.hs:6:
     No instance for (Num [Char])
       arising from use of `*' at tmp.hs:6
     In the definition of `c': c = 3 * "string"

 Which is clearly wrong, since ``c'' is not defined on
 line 6.

 Note I am not sure wether it is in the parser, or it is
 rather in compilation
 chain where cpp gets invoked one has to look for the
 error. I have filed
 it as a parser-bug nonetheless.

 Fix: cpp(1) seems to output comments in the style
 # xx "filename"

 where ``xx'' is a number stating the linenumber in the
 original file.
 Keeping track of this probably fixes the bug.

 CPP version: GNU CPP from GCC 3.3.5
 Operating System: OpenBSD 3.6-current (GENERIC) #1: Sun
 Feb 20 10:23:54 CET 2005

 Submitter: Jesper Louis Andersen <jlouis at mongers.org>

 }}}

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/314>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the Glasgow-haskell-bugs mailing list