return false;
const RecordDecl *RD = dyn_cast<RecordDecl>(FD->getDeclContext());
- if (!RD || !RD->isStruct())
- return false;
+ if (!RD) return false;
+ if (RD->isUnion()) return false;
+ if (const CXXRecordDecl *CRD = dyn_cast<CXXRecordDecl>(RD)) {
+ if (!CRD->isStandardLayout()) return false;
+ }
// See if this is the last field decl in the record.
const Decl *D = FD;
int x;
char c2[1];
};
-
- char bar(struct foo *F) {
- return F->c1[3]; // expected-warning {{array index 3 is past the end of the array (which contains 1 element)}}
- return F->c2[3]; // no warning, foo could have tail padding allocated.
+
+ class baz {
+ public:
+ char c1[1]; // expected-note {{declared here}}
+ int x;
+ char c2[1];
+ };
+
+ char bar(struct foo *F, baz *B) {
+ return F->c1[3] + // expected-warning {{array index 3 is past the end of the array (which contains 1 element)}}
+ F->c2[3] + // no warning, foo could have tail padding allocated.
+ B->c1[3] + // expected-warning {{array index 3 is past the end of the array (which contains 1 element)}}
+ B->c2[3]; // no warning, baz could have tail padding allocated.
}
}