[PATCH] D81913: [AST][RecoveryExpr] Fix a crash on a field decl with invalid type.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 16 03:17:45 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG28923dc2dda4: [AST][RecoveryExpr] Fix a crash on a field decl with invalid type. (authored by hokein).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D81913/new/
https://reviews.llvm.org/D81913
Files:
clang/lib/Sema/SemaDecl.cpp
clang/test/Sema/invalid-member.cpp
Index: clang/test/Sema/invalid-member.cpp
===================================================================
--- clang/test/Sema/invalid-member.cpp
+++ clang/test/Sema/invalid-member.cpp
@@ -13,3 +13,9 @@
};
// Should be able to evaluate sizeof without crashing.
static_assert(sizeof(Y) == 1, "No valid members");
+
+class Z {
+ int array[sizeof(invalid())]; // expected-error {{use of undeclared identifier}}
+};
+// Should be able to evaluate sizeof without crashing.
+static_assert(sizeof(Z) == 1, "No valid members");
Index: clang/lib/Sema/SemaDecl.cpp
===================================================================
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -16479,7 +16479,7 @@
// If we receive a broken type, recover by assuming 'int' and
// marking this declaration as invalid.
- if (T.isNull()) {
+ if (T.isNull() || T->containsErrors()) {
InvalidDecl = true;
T = Context.IntTy;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81913.271014.patch
Type: text/x-patch
Size: 947 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200616/d4d7b31c/attachment.bin>
More information about the cfe-commits
mailing list