Skip to content

Commit 64b8583

Browse files
committed
Warning about non closed (nested) comment
Having code like: ``` #include <stdio.h> int main1(int argc, char **argv) { printf("before \n"); /* printf("in \n"); // */ printf("last \n"); } ``` results in a warning like: ``` aa.cpp:11: warning: Reached end of file while still inside a (nested) comment. Nesting level 2 (probable line reference: 8, 6) ``` as doxygen supports the (non standard) nested comments, though here we have no nested comment as is well signaled by the `/` after the `*`. The code is also valid Cpp code. We now explicitly exclude code like `//*/` from being a start comment.
1 parent 86fe8ce commit 64b8583

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/commentcnv.l

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,10 @@ SLASHopt [/]*
663663
BEGIN(Scan);
664664
}
665665
}
666+
<CComment,CNComment>"/""/"+/"*/" { /* we are already in C-comment so not a start of a nested comment but
667+
* just the end of the comment (the end part is handled later). */
668+
copyToOutput(yyscanner,yytext,(int)yyleng);
669+
}
666670
<CComment,CNComment>"/"+"*" { /* nested C comment */
667671
if (yyextra->lang==SrcLangExt_Python ||
668672
yyextra->lang==SrcLangExt_Markdown)

0 commit comments

Comments
 (0)