mirror of
https://github.com/github/codeql.git
synced 2025-12-22 03:36:30 +01:00
C++: Add test cases for constant initializers
Adds test cases for initialisation of constants which aren't simple zeros. Example: int x = int();
This commit is contained in:
12
cpp/ql/test/duplication-tests/constants/constants.cpp
Normal file
12
cpp/ql/test/duplication-tests/constants/constants.cpp
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
int x = int();
|
||||||
|
float y = float();
|
||||||
|
double z = double();
|
||||||
|
|
||||||
|
/* This produces a getValueText() of 0 for R() in line 9, which is debatable. */
|
||||||
|
struct R {};
|
||||||
|
struct S {
|
||||||
|
S() : S(R()) { }
|
||||||
|
S(R) { }
|
||||||
|
};
|
||||||
|
S s;
|
||||||
4
cpp/ql/test/duplication-tests/constants/expr.expected
Normal file
4
cpp/ql/test/duplication-tests/constants/expr.expected
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
| constants.cpp:2:9:2:13 | 0 | int() |
|
||||||
|
| constants.cpp:3:11:3:17 | 0.0 | float() |
|
||||||
|
| constants.cpp:4:12:4:19 | 0.0 | double() |
|
||||||
|
| constants.cpp:9:11:9:13 | 0 | 0 |
|
||||||
4
cpp/ql/test/duplication-tests/constants/expr.ql
Normal file
4
cpp/ql/test/duplication-tests/constants/expr.ql
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
import cpp
|
||||||
|
|
||||||
|
from Expr e
|
||||||
|
select e, e.getValueText()
|
||||||
Reference in New Issue
Block a user