blob: 35c3d8476f2e27e88afcafc7396703ff2c7a7f0f [file] [log] [blame]
// Test the handling of expressions that depend on template parameters in
// self-assignemnt detection.
// { dg-do compile }
// { dg-options "-Wself-assign" }
template<typename T>
struct Bar {
T x;
Bar operator++(int) {
Bar tmp = *this;
++x;
tmp = tmp; // { dg-warning "assigned to itself" }
return tmp;
}
};
template<typename T>
T DoSomething(T y) {
T a[5], *p;
Bar<T> b;
b.x = b.x;
*p = *p;
a[2] = a[2];
return *p;
}
main() {
Bar<int> bar;
bar++;
DoSomething(5);
}