Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ANDREW.CMU.EDU!sr16+ From: sr16+@ANDREW.CMU.EDU (Seth Benjamin Rothenberg) Newsgroups: gnu.gcc Subject: spotting syntax errors Message-ID: Date: 12 Jul 89 21:23:38 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 26 I recently tried to compile a program with an unclosed comment in it. This caused a syntax error to be detected immediately following the next (correctly closed) comment. (a function header ended up being commented out.) I thought of a simple was to trap this error. Since nested comments generally do cause errors, they should be disallowed. Thus, when the compiler spots a nested comment, it could flag it, including a pointer to original (unclosed) comment. A sample program with this error follows: #include /* this is a buggy program main() { /* another comment to throw you off */ char hi[5]; strcpy(hi, "hi"); /* copy a value in */ puts(hi); } note: char hi[5]; is legal if "main() {" is commented out, so the first error message occurs much later... rejecting nested comments would make finding this error easier.