return false;
case CXXTemporaryObjectExprClass:
- case CXXConstructExprClass:
+ case CXXConstructExprClass: {
+ if (const CXXRecordDecl *Type = getType()->getAsCXXRecordDecl()) {
+ if (Type->hasAttr<WarnUnusedAttr>()) {
+ WarnE = this;
+ Loc = getLocStart();
+ R1 = getSourceRange();
+ return true;
+ }
+ }
return false;
+ }
case ObjCMessageExprClass: {
const ObjCMessageExpr *ME = cast<ObjCMessageExpr>(this);
}
}
+namespace test3 {
+struct Used {
+ Used();
+ Used(int);
+ Used(int, int);
+};
+struct __attribute__((warn_unused)) Unused {
+ Unused();
+ Unused(int);
+ Unused(int, int);
+};
+void f() {
+ Used();
+ Used(1);
+ Used(1, 1);
+ Unused(); // expected-warning {{expression result unused}}
+ Unused(1); // expected-warning {{expression result unused}}
+ Unused(1, 1); // expected-warning {{expression result unused}}
+}
+}