From: Richard Trieu Date: Wed, 7 Sep 2011 00:58:53 +0000 (+0000) Subject: Change the self-reference visitor (which gives the warning for self-reference oninita... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=47eb89871e020babbaddeed4ee4447bc34824b9f;p=clang 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 }; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139213 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index f8b0af49db..9938954fe1 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -5443,6 +5443,7 @@ namespace { } void VisitMemberExpr(MemberExpr *E) { + if (E->getType()->canDecayToPointerType()) return; if (isa(E->getMemberDecl())) if (DeclRefExpr *DRE = dyn_cast(E->getBase()->IgnoreParenImpCasts())) { diff --git a/test/SemaCXX/uninitialized.cpp b/test/SemaCXX/uninitialized.cpp index 462229cec4..c25bd201d6 100644 --- a/test/SemaCXX/uninitialized.cpp +++ b/test/SemaCXX/uninitialized.cpp @@ -115,3 +115,5 @@ struct S { S(char (*)[5]) : x(boo(x)) {} S(char (*)[6]) : x(far(x)) {} }; + +struct C { char a[100], *e; } car = { .e = car.a };