Don't warn about address-to-member used as part of initialisation, if

the member expression is in parentheses.

llvm-svn: 158651
This commit is contained in:
Joerg Sonnenberger
2012-06-17 23:10:39 +00:00
parent e0d4a7c5be
commit 5c98e1fb24
2 changed files with 5 additions and 1 deletions

View File

@@ -6232,7 +6232,7 @@ namespace {
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);
}

View File

@@ -438,6 +438,10 @@ void test54() {
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);