File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
cpp/ql/test/query-tests/jsf/4.10 Classes/AV Rule 82 Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -112,6 +112,28 @@ class Obj2 {
112112 int val;
113113};
114114
115+ struct Exception {
116+ virtual ~Exception ();
117+ };
118+
119+ class AlwaysThrows {
120+ public:
121+ AlwaysThrows &operator =(int _val) { // GOOD [FALSE POSITIVE]
122+ throw Exception ();
123+ // No `return` statement is generated by the C++ front end because it can
124+ // statically see that the end of the function is unreachable.
125+ }
126+
127+ AlwaysThrows &operator =(int *_val) { // GOOD [FALSE POSITIVE]
128+ int one = 1 ;
129+ if (one)
130+ throw Exception ();
131+ // A `return` statement is generated by the C++ front end, but the
132+ // control-flow pruning in QL will establish that this is unreachable.
133+ }
134+ };
135+
136+
115137int main () {
116138 Container c;
117139 c = c;
Original file line number Diff line number Diff line change 22| AV Rule 82.cpp:24:8:24:16 | operator= | Assignment operator in class Bad2 should have return type Bad2&. Otherwise a copy is created at each call. |
33| AV Rule 82.cpp:63:29:63:37 | operator= | Assignment operator in class TemplateReturnAssignment<T> does not return a reference to *this. |
44| AV Rule 82.cpp:63:29:63:37 | operator= | Assignment operator in class TemplateReturnAssignment<int> does not return a reference to *this. |
5+ | AV Rule 82.cpp:121:17:121:25 | operator= | Assignment operator in class AlwaysThrows does not return a reference to *this. |
6+ | AV Rule 82.cpp:127:17:127:25 | operator= | Assignment operator in class AlwaysThrows does not return a reference to *this. |
You can’t perform that action at this time.
0 commit comments