[PATCH] D105451: [clang] Fix crash when there is an invalid declaration with flag -Wcast-align
Queen Dela Cruz via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 5 20:14:05 PDT 2021
qdelacru updated this revision to Diff 356591.
qdelacru added a comment.
Fix format
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D105451/new/
https://reviews.llvm.org/D105451
Files:
clang/lib/Sema/SemaChecking.cpp
clang/test/Sema/warn-cast-align.c
Index: clang/test/Sema/warn-cast-align.c
===================================================================
--- clang/test/Sema/warn-cast-align.c
+++ clang/test/Sema/warn-cast-align.c
@@ -67,3 +67,11 @@
FnTy test5(void) {
return (FnTy)&func5;
}
+
+void test6() {
+ struct {
+ int hello;
+ doesnotexist world;
+ } foo; // expected-error {{unknown type name 'doesnotexist'}}
+ void **repro = (void **)&foo.hello; // expected-warning {{cast from 'int *' to 'void **' increases required alignment from 4 to 8}}
+}
Index: clang/lib/Sema/SemaChecking.cpp
===================================================================
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -14475,7 +14475,8 @@
case Stmt::MemberExprClass: {
auto *ME = cast<MemberExpr>(E);
auto *FD = dyn_cast<FieldDecl>(ME->getMemberDecl());
- if (!FD || FD->getType()->isReferenceType())
+ if (!FD || FD->getType()->isReferenceType() ||
+ FD->getParent()->isInvalidDecl())
break;
Optional<std::pair<CharUnits, CharUnits>> P;
if (ME->isArrow())
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105451.356591.patch
Type: text/x-patch
Size: 1118 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210706/c5297fce/attachment.bin>
More information about the cfe-commits
mailing list