Skip to content

Commit b5a2a2e

Browse files
committed
C++: test for global var access in a global var
1 parent fe52dd9 commit b5a2a2e

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

cpp/ql/test/library-tests/ir/ir/ir.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1766,4 +1766,6 @@ constructor_only global_5 = constructor_only(2);
17661766

17671767
char *global_string = "global string";
17681768

1769+
int global_6 = global_2;
1770+
17691771
// semmle-extractor-options: -std=c++17 --clang

cpp/ql/test/library-tests/ir/ir/raw_consistency.expected

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,7 @@ nonUniqueEnclosingIRFunction
2828
fieldAddressOnNonPointer
2929
thisArgumentIsNonPointer
3030
nonUniqueIRVariable
31-
| ir.cpp:1038:6:1038:8 | VariableAddress: lam | Variable address instruction 'VariableAddress: lam' has no associated variable, in function '$@'. | ir.cpp:1038:6:1038:8 | (lambda [] type at line 1038, col. 12) lam | (lambda [] type at line 1038, col. 12) lam |
32-
| ir.cpp:1759:5:1759:12 | VariableAddress: global_2 | Variable address instruction 'VariableAddress: global_2' has no associated variable, in function '$@'. | ir.cpp:1759:5:1759:12 | int global_2 | int global_2 |
33-
| ir.cpp:1761:11:1761:18 | VariableAddress: global_3 | Variable address instruction 'VariableAddress: global_3' has no associated variable, in function '$@'. | ir.cpp:1761:11:1761:18 | int const global_3 | int const global_3 |
34-
| ir.cpp:1763:18:1763:25 | VariableAddress: global_4 | Variable address instruction 'VariableAddress: global_4' has no associated variable, in function '$@'. | ir.cpp:1763:18:1763:25 | constructor_only global_4 | constructor_only global_4 |
35-
| ir.cpp:1765:18:1765:25 | VariableAddress: global_5 | Variable address instruction 'VariableAddress: global_5' has no associated variable, in function '$@'. | ir.cpp:1765:18:1765:25 | constructor_only global_5 | constructor_only global_5 |
36-
| ir.cpp:1767:7:1767:19 | VariableAddress: global_string | Variable address instruction 'VariableAddress: global_string' has no associated variable, in function '$@'. | ir.cpp:1767:7:1767:19 | char* global_string | char* global_string |
37-
| struct_init.cpp:9:13:9:25 | VariableAddress: infos_in_file | Variable address instruction 'VariableAddress: infos_in_file' has no associated variable, in function '$@'. | struct_init.cpp:9:13:9:25 | Info infos_in_file[] | Info infos_in_file[] |
31+
| ir.cpp:1769:16:1769:23 | VariableAddress: global_2 | Variable address instruction 'VariableAddress: global_2' has no associated variable, in function '$@'. | ir.cpp:1769:5:1769:12 | int global_6 | int global_6 |
3832
missingCanonicalLanguageType
3933
multipleCanonicalLanguageTypes
4034
missingIRType

cpp/ql/test/library-tests/ir/ir/raw_ir.expected

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9494,6 +9494,18 @@ ir.cpp:
94949494
# 1767| v1767_9(void) = AliasedUse : ~m?
94959495
# 1767| v1767_10(void) = ExitFunction :
94969496

9497+
# 1769| int global_6
9498+
# 1769| Block 0
9499+
# 1769| v1769_1(void) = EnterFunction :
9500+
# 1769| mu1769_2(unknown) = AliasedDefinition :
9501+
# 1769| r1769_3(glval<int>) = VariableAddress[global_6] :
9502+
# 1769| r1769_4(glval<int>) = VariableAddress :
9503+
# 1769| r1769_5(int) = Load[?] : &:r1769_4, ~m?
9504+
# 1769| mu1769_6(int) = Store[global_6] : &:r1769_3, r1769_5
9505+
# 1769| v1769_7(void) = ReturnVoid :
9506+
# 1769| v1769_8(void) = AliasedUse : ~m?
9507+
# 1769| v1769_9(void) = ExitFunction :
9508+
94979509
perf-regression.cpp:
94989510
# 6| void Big::Big()
94999511
# 6| Block 0

0 commit comments

Comments
 (0)