Skip to content

Commit 309a8e6

Browse files
committed
C++: add more test cases for the type of this
1 parent e79625e commit 309a8e6

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

cpp/ql/test/library-tests/members/this/test.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ class C {
3535
// No use of `this`, but we still expect to be able to get its type.
3636
global++;
3737
}
38+
39+
float f7() const & {
40+
// We expect the type of `this` to be const-qualified.
41+
return x;
42+
}
43+
44+
float f8() && {
45+
// We expect the type of `this` to be unqualified.
46+
return x;
47+
}
3848
};
3949

4050
// We want to test that D* is in the database even when there's no use of it,

cpp/ql/test/library-tests/members/this/this.expected

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@ thisExprType
44
| test.cpp:21:12:21:12 | this | file://:0:0:0:0 | const C * |
55
| test.cpp:26:12:26:12 | this | file://:0:0:0:0 | volatile C * |
66
| test.cpp:31:12:31:12 | this | file://:0:0:0:0 | const volatile C * |
7+
| test.cpp:41:12:41:12 | this | file://:0:0:0:0 | const C * |
8+
| test.cpp:46:12:46:12 | this | file://:0:0:0:0 | C * |
79
#select
810
| test.cpp:9:8:9:9 | f1 | file://:0:0:0:0 | C * |
911
| test.cpp:14:8:14:9 | f2 | file://:0:0:0:0 | C * |
1012
| test.cpp:19:7:19:8 | f3 | file://:0:0:0:0 | const C * |
1113
| test.cpp:24:7:24:8 | f4 | file://:0:0:0:0 | volatile C * |
1214
| test.cpp:29:7:29:8 | f5 | file://:0:0:0:0 | const volatile C * |
1315
| test.cpp:34:8:34:9 | f6 | file://:0:0:0:0 | C * |
14-
| test.cpp:43:8:43:8 | f | file://:0:0:0:0 | D * |
16+
| test.cpp:39:9:39:10 | f7 | file://:0:0:0:0 | const C * |
17+
| test.cpp:44:9:44:10 | f8 | file://:0:0:0:0 | C * |
18+
| test.cpp:53:8:53:8 | f | file://:0:0:0:0 | D * |

0 commit comments

Comments
 (0)