diff options
author | Richard Trieu <rtrieu@google.com> | 2016-03-31 04:18:07 +0000 |
---|---|---|
committer | Richard Trieu <rtrieu@google.com> | 2016-03-31 04:18:07 +0000 |
commit | 1c7237ae619d3d1d455f48a601e72c2795f81e40 (patch) | |
tree | 709ff8e14d7d52e9748fe12a21a49e16c7e0fa32 | |
parent | 936a2b09f366267454b7cff9ffb9e76240137bf8 (diff) | |
download | bcm5719-llvm-1c7237ae619d3d1d455f48a601e72c2795f81e40.tar.gz bcm5719-llvm-1c7237ae619d3d1d455f48a601e72c2795f81e40.zip |
Fix -Wdynamic-class-memaccess to skip invalid classes.
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
-rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 2 | ||||
-rw-r--r-- | clang/test/SemaCXX/warn-bad-memaccess.cpp | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 43195bd64ff..ee39401d48a 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -5611,7 +5611,7 @@ static const CXXRecordDecl *getContainedDynamicClass(QualType T, const CXXRecordDecl *RD = Ty->getAsCXXRecordDecl(); RD = RD ? RD->getDefinition() : nullptr; - if (!RD) + if (!RD || RD->isInvalidDecl()) return nullptr; if (RD->isDynamicClass()) diff --git a/clang/test/SemaCXX/warn-bad-memaccess.cpp b/clang/test/SemaCXX/warn-bad-memaccess.cpp index 67cde10bf45..55ce4a0da03 100644 --- a/clang/test/SemaCXX/warn-bad-memaccess.cpp +++ b/clang/test/SemaCXX/warn-bad-memaccess.cpp @@ -141,3 +141,16 @@ namespace N { 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; +} +} |