diff --git a/src/cc65/global.c b/src/cc65/global.c index 8b9838dc5..b2c3ef0a0 100644 --- a/src/cc65/global.c +++ b/src/cc65/global.c @@ -49,6 +49,7 @@ unsigned char DebugInfo = 0; /* Add debug info to the obj */ unsigned char PreprocessOnly = 0; /* Just preprocess the input */ unsigned char DebugOptOutput = 0; /* Output debug stuff */ unsigned RegisterSpace = 6; /* Space available for register vars */ +unsigned AllowNewComments = 0; /* Allow new style comments in C89 mode */ /* Stackable options */ IntStack WritableStrings = INTSTACK(0); /* Literal strings are r/w */ diff --git a/src/cc65/global.h b/src/cc65/global.h index 266035346..ba7105130 100644 --- a/src/cc65/global.h +++ b/src/cc65/global.h @@ -57,6 +57,7 @@ extern unsigned char DebugInfo; /* Add debug info to the obj */ extern unsigned char PreprocessOnly; /* Just preprocess the input */ extern unsigned char DebugOptOutput; /* Output debug stuff */ extern unsigned RegisterSpace; /* Space available for register vars */ +extern unsigned AllowNewComments; /* Allow new style comments in C89 mode */ /* Stackable options */ extern IntStack WritableStrings; /* Literal strings are r/w */ diff --git a/src/cc65/preproc.c b/src/cc65/preproc.c index 020df011a..56331266f 100644 --- a/src/cc65/preproc.c +++ b/src/cc65/preproc.c @@ -402,8 +402,10 @@ static void NewStyleComment (void) /* Remove a new style C comment from line. */ { /* Diagnose if this is unsupported */ - if (IS_Get (&Standard) < STD_C99) { + if (IS_Get (&Standard) < STD_C99 && !AllowNewComments) { PPError ("C++ style comments are not allowed in C89"); + PPNote ("(this will be reported only once per input file)"); + AllowNewComments = 1; } /* Beware: Because line continuation chars are handled when reading @@ -1800,6 +1802,9 @@ void PreprocessBegin (void) /* Remember to update source file location in preprocess-only mode */ FileChanged = 1; + + /* Enable diagnostics on new style comments in C89 mode */ + AllowNewComments = 0; }