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:
Matthew Gretton-Dann
2019-09-20 14:20:25 +01:00
parent fb20cab4c8
commit b76f66e83b
3 changed files with 20 additions and 0 deletions

View 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;

View 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 |

View File

@@ -0,0 +1,4 @@
import cpp
from Expr e
select e, e.getValueText()