summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2019-07-16 01:13:36 +0000
committerPeter Wu <peter@lekensteyn.nl>2019-07-16 01:13:36 +0000
commitfa52e00c85ce3feeec14be34265781f721b966c0 (patch)
tree39f47928bcf49eabec1c274adf43008edcbfbdf4 /clang/lib/AST
parent543ba4e9e0c421bedaea2d8a0f1965092cec300e (diff)
downloadbcm5719-llvm-fa52e00c85ce3feeec14be34265781f721b966c0.tar.gz
bcm5719-llvm-fa52e00c85ce3feeec14be34265781f721b966c0.zip
[Sema] Suppress additional warnings for C's zero initializer
Summary: D28148 relaxed some checks for assigning { 0 } to a structure for all C standards, but it failed to handle structures with non-integer subobjects. Relax -Wmissing-braces checks for such structures, and add some additional tests. This fixes PR39931. Patch By: al3xtjames Reviewed By: Lekensteyn Differential Revision: https://reviews.llvm.org/D61838 llvm-svn: 366163
Diffstat (limited to 'clang/lib/AST')
-rw-r--r--clang/lib/AST/Expr.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index f8017bb7ade..10ab2bf72b7 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -2303,11 +2303,11 @@ bool InitListExpr::isTransparent() const {
bool InitListExpr::isIdiomaticZeroInitializer(const LangOptions &LangOpts) const {
assert(isSyntacticForm() && "only test syntactic form as zero initializer");
- if (LangOpts.CPlusPlus || getNumInits() != 1) {
+ if (LangOpts.CPlusPlus || getNumInits() != 1 || !getInit(0)) {
return false;
}
- const IntegerLiteral *Lit = dyn_cast<IntegerLiteral>(getInit(0));
+ const IntegerLiteral *Lit = dyn_cast<IntegerLiteral>(getInit(0)->IgnoreImplicit());
return Lit && Lit->getValue() == 0;
}
OpenPOWER on IntegriCloud