Hello!
Report a Bug about Parsing #ifdef, #ifndef and #else Line.
--------------------------------------------------------------------------------
Bug info:
File: tccpp.c
Function: preprocess, preprocess_skip
Line: 1813, 1816, 1842
--------------------------------------------------------------------------------
Test code:
#include <stdio.h>
#define Test
int main(int argc, const char **argv)
{
#ifndef Test
#else
printf("Hello, Test\n");
#endif
printf("Hello, World\n");
return 0;
}
Hello, Test Hello, World
--------------------------------------------------------------------------------
Problem:
In the preprocess function, when analyzing lines containing
preprocessor
directives such as #ifndef, #ifdef, and #else, the entire line
is not
being fully read. When the conditions for a branch are not met and the
preprocess_skip function is invoked to skip over subsequent code,
issues arise because preprocess_skip assumes it is starting at
the
beginning of a new line.
As in the code above, it is possible to insert a large amount of
whitespace
before an #else directive on a single line. If the #else is
not properly
detected due to this issue, it can cause confusion and make it difficult
for someone to identify the root cause.
--------------------------------------------------------------------------------
Fix:
According to your decision.
837806295
837806...@qq.com
_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel