[cfe-commits] r139213 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/SemaCXX/uninitialized.cpp

Richard Trieu rtrieu at google.com
Tue Sep 6 17:58:53 PDT 2011


Author: rtrieu
Date: Tue Sep  6 19:58:53 2011
New Revision: 139213

URL: http://llvm.org/viewvc/llvm-project?rev=139213&view=rev
Log:
Change the self-reference visitor (which gives the warning for self-reference oninitalization warning of -Wuninitialized) to exclude member variables that can decay into pointers.  This will cause it to no longer warn on this code:

struct foo { char a[100], *e; } bar = { .e = bar.a };

Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/SemaCXX/uninitialized.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=139213&r1=139212&r2=139213&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Sep  6 19:58:53 2011
@@ -5443,6 +5443,7 @@
     }
 
     void VisitMemberExpr(MemberExpr *E) {
+      if (E->getType()->canDecayToPointerType()) return;
       if (isa<FieldDecl>(E->getMemberDecl()))
         if (DeclRefExpr *DRE
               = dyn_cast<DeclRefExpr>(E->getBase()->IgnoreParenImpCasts())) {

Modified: cfe/trunk/test/SemaCXX/uninitialized.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/uninitialized.cpp?rev=139213&r1=139212&r2=139213&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/uninitialized.cpp (original)
+++ cfe/trunk/test/SemaCXX/uninitialized.cpp Tue Sep  6 19:58:53 2011
@@ -115,3 +115,5 @@
   S(char (*)[5]) : x(boo(x)) {}
   S(char (*)[6]) : x(far(x)) {}
 };
+
+struct C { char a[100], *e; } car = { .e = car.a };





More information about the cfe-commits mailing list