-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17608 from jketema/macro-expansion-tests
C++: Add more macro expansion tests
- Loading branch information
Showing
2 changed files
with
235 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 79 additions & 2 deletions
81
cpp/ql/test/library-tests/macros/inmacroexpansion/test.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,82 @@ | ||
|
||
#define FOO class S{int i; void f(void) { int j; return; } }; | ||
#define CLASS_DECL class S{int i; void f(void) { int j; return; } }; | ||
|
||
FOO | ||
CLASS_DECL | ||
|
||
#define FUNCTION_DECL void f1() { int k; } | ||
|
||
FUNCTION_DECL | ||
|
||
#define VARIABLE_DECL int v1 = 1; | ||
|
||
VARIABLE_DECL | ||
|
||
#define TYPE_DECL_1 typedef int t1; | ||
|
||
TYPE_DECL_1 | ||
|
||
#define TYPE_DECL_2 using t2 = int; | ||
|
||
TYPE_DECL_2 | ||
|
||
#define NAMESPACE_DECL namespace ns { int v2; } | ||
|
||
NAMESPACE_DECL | ||
|
||
#define USING_NAMESPACE using namespace ns; | ||
|
||
#define ENUM_CONSTANT enum_element | ||
|
||
enum class enum_class { ENUM_CONSTANT }; | ||
|
||
#define USING_ENUM using enum enum_class; | ||
|
||
USING_ENUM | ||
|
||
#define STATIC_ASSERT static_assert(1 == 1, ""); | ||
|
||
STATIC_ASSERT | ||
|
||
#define ATTRIBUTE [[nodiscard("reason1")]] | ||
|
||
ATTRIBUTE | ||
int f2(); | ||
|
||
#define ATTRIBUTE_ARG "reason2" | ||
|
||
[[nodiscard(ATTRIBUTE_ARG)]] | ||
int f3(); | ||
|
||
#define TYPE int | ||
|
||
TYPE v3 = 1; | ||
|
||
#define DERIVATION : public S | ||
|
||
class T DERIVATION {}; | ||
|
||
#define FRIEND friend int f3(); | ||
|
||
class U { | ||
FRIEND | ||
}; | ||
|
||
#define NAME_QUAL_1 ns:: | ||
|
||
#define NAME_QUAL_2 ns | ||
|
||
#define LOCAL_VAR m | ||
|
||
void f4() { | ||
NAME_QUAL_1 v2; | ||
NAME_QUAL_2 :: v2; | ||
int LOCAL_VAR = 42; | ||
auto l = [LOCAL_VAR]() { return m; }; | ||
l(); | ||
} | ||
|
||
#define ID(x) x | ||
#define NESTED(x) ID(x) | ||
int v4 = NESTED(1); | ||
|
||
// semmle-extractor-options: -std=c++20 |