[cfe-commits] r158651 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/Sema/uninit-variables.c

Joerg Sonnenberger joerg at bec.de
Sun Jun 17 16:10:39 PDT 2012


Author: joerg
Date: Sun Jun 17 18:10:39 2012
New Revision: 158651

URL: http://llvm.org/viewvc/llvm-project?rev=158651&view=rev
Log:
Don't warn about address-to-member used as part of initialisation, if
the member expression is in parentheses.

Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/Sema/uninit-variables.c

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=158651&r1=158650&r2=158651&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sun Jun 17 18:10:39 2012
@@ -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);
     } 
 

Modified: cfe/trunk/test/Sema/uninit-variables.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/uninit-variables.c?rev=158651&r1=158650&r2=158651&view=diff
==============================================================================
--- cfe/trunk/test/Sema/uninit-variables.c (original)
+++ cfe/trunk/test/Sema/uninit-variables.c Sun Jun 17 18:10:39 2012
@@ -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);





More information about the cfe-commits mailing list