CPP: Add cases for fields.

This commit is contained in:
Geoffrey White
2019-06-10 14:42:25 +01:00
parent d3f98a5a74
commit 2f36d81137
2 changed files with 38 additions and 0 deletions

View File

@@ -1,3 +1,5 @@
| file://:0:0:0:0 | abc | test.cpp:53:6:53:11 | chars1 |
| file://:0:0:0:0 | {...} | test.cpp:38:22:38:22 | v |
| test.cpp:4:9:4:11 | 10 | test.cpp:4:6:4:6 | v |
| test.cpp:5:15:5:16 | & ... | test.cpp:5:7:5:11 | ptr_v |
| test.cpp:6:15:6:15 | v | test.cpp:6:7:6:11 | ref_v |
@@ -8,3 +10,9 @@
| test.cpp:19:42:19:43 | _x | test.cpp:24:8:24:8 | x |
| test.cpp:19:49:19:50 | _y | test.cpp:24:11:24:11 | y |
| test.cpp:19:54:19:60 | 0.0 | test.cpp:24:14:24:14 | z |
| test.cpp:35:16:35:25 | {...} | test.cpp:35:11:35:12 | v1 |
| test.cpp:36:16:36:39 | {...} | test.cpp:36:11:36:12 | v2 |
| test.cpp:48:16:48:28 | {...} | test.cpp:48:11:48:12 | v3 |
| test.cpp:52:19:52:27 | {...} | test.cpp:52:5:52:11 | myArray |
| test.cpp:54:17:54:31 | {...} | test.cpp:54:6:54:11 | chars2 |
| test.cpp:55:16:55:20 | abc | test.cpp:55:7:55:12 | chars3 |

View File

@@ -23,3 +23,33 @@ public:
private:
float x, y, z;
};
// ---
struct myStruct1
{
int num;
const char *str;
};
myStruct1 v1 = {1, "One"}; // assigment to `v1`
myStruct1 v2 = {.num = 2, .str = "Two"}; // assigment to `v2`
void test2(myStruct1 v = {3, "Three"}) // assignment to `v` (literal `{...}` has no location)
{
// ...
}
struct myStruct2
{
myStruct1 ms2;
};
myStruct2 v3 = {{4, "Four"}}; // assigment to `v3`
// ---
int myArray[10] = {1, 2, 3}; // assigment to `myArray`
char chars1[] = "abc"; // assignment to `chars1` (literal "abc" has no location)
char chars2[] = {'a', 'b', 'c'}; // assigment to `chars2`
char *chars3 = "abc"; // assigment to `chars3`