Skip to content

Commit

Permalink
C++: Uncomment preprocessor test cases and add addition #if test case
Browse files Browse the repository at this point in the history
Note that the new test case shows that line splicing is not correctly handled
in the case of `#if`.
  • Loading branch information
jketema committed Jan 16, 2025
1 parent 02ac61f commit dca87f3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
7 changes: 7 additions & 0 deletions cpp/ql/test/library-tests/preprocessor/preprocessor/pp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,10 @@ int templateClassContext<T> :: val = MACRO_TEMPLATECLASSCONTEXT_REFERENCED;

#define INSTANTIATION
templateClassContext<int> tcci;

#define BAR

#if defined(BAR) && \
defined(BAR)
#warning BAR defined
#endif
8 changes: 4 additions & 4 deletions cpp/ql/test/library-tests/preprocessor/preprocessor/pp.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
//#pragma byte_order(big_endian)
#warning "Not in Kansas any more"

//#define MULTILINE \
#define MULTILINE \
/* Hello */ \
world \
/* from */ \
a long \
/* macro */
//#undef \
#undef \
MULTILINE

//#include \
<pp.h> \
#include \
"pp.h" \
\
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@
| pp.cpp:0:0:0:0 | pp.cpp | 60 | 3 | 60 | 21 | Macro | IN_TEMPLATE | |
| pp.cpp:0:0:0:0 | pp.cpp | 61 | 1 | 61 | 7 | PreprocessorEndif | N/A | N/A |
| pp.cpp:0:0:0:0 | pp.cpp | 69 | 1 | 69 | 21 | Macro | INSTANTIATION | |
| pp.cpp:0:0:0:0 | pp.cpp | 72 | 1 | 72 | 11 | Macro | BAR | |
| pp.cpp:0:0:0:0 | pp.cpp | 74 | 1 | 74 | 21 | PreprocessorIf | defined(BAR) && \\ | N/A |
| pp.cpp:0:0:0:0 | pp.cpp | 76 | 1 | 76 | 20 | PreprocessorWarning | BAR defined | N/A |
| pp.cpp:0:0:0:0 | pp.cpp | 77 | 1 | 77 | 6 | PreprocessorEndif | N/A | N/A |
| pp.h:0:0:0:0 | pp.h | 1 | 1 | 1 | 12 | PreprocessorPragma | once | N/A |
| pp.h:0:0:0:0 | pp.h | 3 | 1 | 3 | 27 | PreprocessorLine | 33 "emerald_city.h" | N/A |
| pp.h:0:0:0:0 | pp.h | 5 | 1 | 5 | 33 | PreprocessorWarning | "Not in Kansas any more" | N/A |
| pp.h:0:0:0:0 | pp.h | 7 | 1 | 11 | 8 | Macro | MULTILINE | world a long |
| pp.h:0:0:0:0 | pp.h | 13 | 1 | 14 | 11 | PreprocessorUndef | MULTILINE | N/A |
| pp.h:0:0:0:0 | pp.h | 16 | 1 | 17 | 8 | Include | "pp.h" | N/A |

0 comments on commit dca87f3

Please sign in to comment.