Skip to content

Commit e7dfb3e

Browse files
committed
C++: Test for x-macro FP observed in the wild
1 parent 1bd0c69 commit e7dfb3e

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

cpp/ql/test/query-tests/jsf/4.07 Header Files/AV Rule 35/AV Rule 35.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
| complexcondition2.h:0:0:0:0 | complexcondition2.h | This header file should contain a header guard to prevent multiple inclusion. | file://:0:0:0:0 | | | file://:0:0:0:0 | | |
22
| complexcondition.h:0:0:0:0 | complexcondition.h | This header file should contain a header guard to prevent multiple inclusion. | file://:0:0:0:0 | | | file://:0:0:0:0 | | |
33
| fundecl.h:0:0:0:0 | fundecl.h | This header file should contain a header guard to prevent multiple inclusion. | file://:0:0:0:0 | | | file://:0:0:0:0 | | |
4+
| items3.h:0:0:0:0 | items3.h | This header file should contain a header guard to prevent multiple inclusion. | file://:0:0:0:0 | | | file://:0:0:0:0 | | |
45
| multipleguards.h:0:0:0:0 | multipleguards.h | This header file should contain a header guard to prevent multiple inclusion ($@ matching $@ occurs before the end of the file). | multipleguards.h:7:1:7:6 | #endif | #endif | multipleguards.h:2:1:2:24 | #ifndef MULTIPLEGUARDS_H | #ifndef MULTIPLEGUARDS_H |
56
| namespace1.h:0:0:0:0 | namespace1.h | This header file should contain a header guard to prevent multiple inclusion. | file://:0:0:0:0 | | | file://:0:0:0:0 | | |
67
| namespace2.h:0:0:0:0 | namespace2.h | This header file should contain a header guard to prevent multiple inclusion. | file://:0:0:0:0 | | | file://:0:0:0:0 | | |

cpp/ql/test/query-tests/jsf/4.07 Header Files/AV Rule 35/all1.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,8 @@ enum Items {
5353
#define XMACRO2(id,desc) void use_##();
5454
#include "items2.h"
5555
#undef XMACRO2
56+
57+
58+
#define XMACRO3(id,desc) static const char * id##_item = "The " desc " item";
59+
#include "items3.h"
60+
// No #undef of XMACRO3. That's handled in items3.h.

cpp/ql/test/query-tests/jsf/4.07 Header Files/AV Rule 35/all2.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,7 @@ enum Items {
3232
#define XMACRO2(id,desc) void use_##();
3333
#include "items2.h"
3434
#undef XMACRO2
35+
36+
#define XMACRO3(id,desc) static const char * id##_name = desc;
37+
#include "items3.h"
38+
// No #undef of XMACRO3. That's handled in items3.h.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
XMACRO3(shield, "Wooden Shield")
2+
XMACRO3(boots, "Leather Boots")
3+
XMACRO3(helmet, "Helmet")
4+
5+
#undef XMACRO3

0 commit comments

Comments
 (0)