Don't warn about address-to-member used as part of initialisation, if
the member expression is in parentheses.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158651 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index d98ce6b..63385cc 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -6232,7 +6232,7 @@
void VisitUnaryOperator(UnaryOperator *E) {
// For POD record types, addresses of its own members are well-defined.
if (E->getOpcode() == UO_AddrOf && isRecordType && isPODType &&
- isa<MemberExpr>(E->getSubExpr())) return;
+ isa<MemberExpr>(E->getSubExpr()->IgnoreParens())) return;
Inherited::VisitUnaryOperator(E);
}
diff --git a/test/Sema/uninit-variables.c b/test/Sema/uninit-variables.c
index 180d60c..59577b9 100644
--- a/test/Sema/uninit-variables.c
+++ b/test/Sema/uninit-variables.c
@@ -438,6 +438,10 @@
ASSIGN(int, c, d); // expected-warning {{variable 'c' is uninitialized when used here}}
}
+// Taking the address is fine
+struct { struct { void *p; } a; } test55 = { { &test55.a }}; // no-warning
+struct { struct { void *p; } a; } test56 = { { &(test56.a) }}; // no-warning
+
void uninit_in_loop() {
int produce(void);
void consume(int);