case '/':
next_char();
if (c == '*') {
- /* TODO: nested comment, warn here */
+ /* nested comment, warn here */
+ if (warning.comment) {
+ warningf(&lexer_token.source_position, "'/*' within comment");
+ }
}
break;
case '*':
case '\r':
return;
+ case '\\':
+ next_char();
+ if (c == '\n' || c == '\r') {
+ if (warning.comment)
+ warningf(&lexer_token.source_position, "multi-line comment");
+ return;
+ }
+ break;
+
default:
next_char();
break;
.attribute = true,
.char_subscripts = true,
.cast_qual = false,
+ .comment = false,
.declaration_after_statement = false,
.deprecated_declarations = true,
.div_by_zero = true,
/* Note: this switched on a lot of more warnings than gcc's -Wall */
SET(attribute);
SET(char_subscripts);
- // TODO SET(comment);
+ SET(comment);
SET(empty_statement);
SET(format);
SET(implicit_function_declaration);
OPT("attribute", attribute);
OPT("char-subscripts", char_subscripts);
OPT("cast-qual", cast_qual);
+ OPT("comment", comment);
OPT("declaration-after-statement", declaration_after_statement);
OPT("deprecated-declarations", deprecated_declarations);
OPT("div_by_zero", div_by_zero);
#if 0 // TODO
bool cast_align:1; /**< Warn whenever a pointer is cast such that the required alignment of the target is increased */
bool conversion:1; /**< Warn if a prototype causes a type conversion that is different from what would happen to the same argument in the absence of a prototype */
- bool comment:1; /**< Warn whenever a comment-start sequence appears in a comment, or whenever a Backslash-Newline appears in a '//' comment. */
#endif
+ bool comment:1; /**< Warn whenever a comment-start sequence appears in a comment, or whenever a Backslash-Newline appears in a '//' comment. */
bool declaration_after_statement:1; /**< Warn when a declaration is found after a statement in a block */
bool deprecated_declarations:1; /* TODO implement for types */ /**< Warn about uses of functions, variables and types marked as deprecated by using the 'deprecated' attribute */
bool div_by_zero:1; /**< Warn about compile-time integer division by zero */