Bugs item #1153674, was opened at 2005-02-28 18:09
Message generated for change (Comment added) made by simonmar
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=108032&aid=1153674&group_id=8032

Category: Compiler (Parser)
>Group: 6.4
Status: Open
Resolution: None
>Priority: 3
Submitted By: Nobody/Anonymous (nobody)
>Assigned to: Simon Marlow (simonmar)
>Summary: #line pragmas not respected inside nested comments

Initial Comment:
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
<[EMAIL PROTECTED]>
 *
 * 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 <[EMAIL PROTECTED]>


----------------------------------------------------------------------

>Comment By: Simon Marlow (simonmar)
Date: 2005-03-04 11:17

Message:
Logged In: YES 
user_id=48280

Thanks for the report.

GHC does recognise the #line pragmas generated by gcc/cpp,
but unfortunately it doesn't respect them inside {- -} comments.

To fix your example, just remove the {- -} comments around
the C comment.

It isn't an easy fix, so I've renamed the bug and downgraded
it for now.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=108032&aid=1153674&group_id=8032
_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to