Issue Details (XML | Word | Printable)

Key: PCC-126
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Iain Hibbert
Votes: 0
Watchers: 0

If you were logged in you would be able to see more operations.

C preprocessor cannot handle comments in conditional expressions

Created: 17/Apr/10 03:43 PM   Updated: 18/Apr/10 07:08 PM
Component/s: C preprocessor
Affects Version/s: None
Fix Version/s: None

Environment: pcc-20100417 on NetBSD

 Description  « Hide
As per the following code

#define FOO 1 /* foo */
#define BAR 2 /* bar */

#define BAZ FOO

#if BAZ == FOO
int foo = FOO;
#elif BAZ == BAR
int bar = BAR;
#error "unknown BAZ"

when compiled with "pcc -E -C" as for instance using lint on NetBSD, cpp will fail with a syntax error because of the comments contained within the tokens of the expressions. The original scanner.l code (btw please remove it, or else put a "XXXX this code is unused XXXX" at the top :) seemed to have a mechanism to handle this, but the new token.c does not. I think that the fix would be to handle comments in cpy.y ?

This bug shows up using lint on NetBSD which passes "-Wp,-CC" to the compiler to leave comments in, so "make CC=pcc" in usr.bin/xlint/llib and most libraries will fail with a syntax error in <sys/endian.h>

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Anders Magnusson added a comment - 18/Apr/10 07:08 PM
Fixed by ignoring comments in #if statement evaluation.