This warning sometimes will infinitely recurse on CXXRecordDecl's from
ill-formed recursive classes that have fields of themselves. Skip processing
these classes to prevent this from happening.
Fixes https://llvm.org/bugs/show_bug.cgi?id=27142
llvm-svn: 264991
const CXXRecordDecl *RD = Ty->getAsCXXRecordDecl();
RD = RD ? RD->getDefinition() : nullptr;
- if (!RD)
+ if (!RD || RD->isInvalidDecl())
return nullptr;
if (RD->isDynamicClass())
N::memset(&x1, 0, sizeof x1);
}
}
+
+namespace recursive_class {
+struct S {
+ S v;
+ // expected-error@-1{{field has incomplete type 'recursive_class::S'}}
+ // expected-note@-3{{definition of 'recursive_class::S' is not complete until the closing '}'}}
+} a;
+
+int main() {
+ __builtin_memset(&a, 0, sizeof a);
+ return 0;
+}
+}