mirror of
https://github.com/github/codeql.git
synced 2026-04-27 17:55:19 +02:00
C++: Add test with FP in ExprHasNoEffect
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
| test.cpp:25:3:25:3 | call to operator++ | This expression has no effect (because $@ has no external side effects). | test.cpp:9:14:9:23 | operator++ | operator++ |
|
||||
| test.cpp:62:5:62:5 | call to operator= | This expression has no effect (because $@ has no external side effects). | test.cpp:47:14:47:22 | operator= | operator= |
|
||||
| test.cpp:65:5:65:5 | call to operator= | This expression has no effect (because $@ has no external side effects). | test.cpp:55:7:55:7 | operator= | operator= |
|
||||
| test.cpp:91:5:91:19 | call to operator= | This expression has no effect (because $@ has no external side effects). | test.cpp:77:9:77:17 | operator= | operator= |
|
||||
| volatile.c:9:5:9:5 | c | This expression has no effect. | volatile.c:9:5:9:5 | c | |
|
||||
| volatile.c:12:5:12:9 | access to array | This expression has no effect. | volatile.c:12:5:12:9 | access to array | |
|
||||
| volatile.c:16:5:16:7 | * ... | This expression has no effect. | volatile.c:16:5:16:7 | * ... | |
|
||||
|
||||
@@ -64,3 +64,45 @@ void testFunc2()
|
||||
MyAssignable v1, v2;
|
||||
v2 = v1;
|
||||
}
|
||||
|
||||
namespace std {
|
||||
typedef unsigned long size_t;
|
||||
}
|
||||
|
||||
void* operator new (std::size_t size, void* ptr) noexcept;
|
||||
|
||||
struct Base {
|
||||
Base() { }
|
||||
|
||||
Base &operator=(const Base &rhs) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
virtual ~Base() { }
|
||||
};
|
||||
|
||||
struct Derived : Base {
|
||||
Derived &operator=(const Derived &rhs) {
|
||||
if (&rhs == this) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
// In case base class has data, now or in the future, copy that first.
|
||||
Base::operator=(rhs); // GOOD [FALSE POSITIVE]
|
||||
|
||||
this->m_x = rhs.m_x;
|
||||
return *this;
|
||||
}
|
||||
|
||||
int m_x;
|
||||
};
|
||||
|
||||
void use_Base() {
|
||||
Base base_buffer[1];
|
||||
Base *base = new(&base_buffer[0]) Base();
|
||||
|
||||
// In case the destructor does something, now or in the future, call it. It
|
||||
// won't get called automatically because the object was allocated with
|
||||
// placement new.
|
||||
base->~Base(); // GOOD (because the call has void type)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user