[llvm-branch-commits] [cfe-branch] r367150 - Merging r367134:

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Jul 26 13:47:20 PDT 2019


Author: hans
Date: Fri Jul 26 13:47:20 2019
New Revision: 367150

URL: http://llvm.org/viewvc/llvm-project?rev=367150&view=rev
Log:
Merging r367134:
------------------------------------------------------------------------
r367134 | nathan-huckleberry | 2019-07-26 19:29:35 +0200 (Fri, 26 Jul 2019) | 16 lines

[Sema] Fix -Wuninitialized for struct assignment from GNU C statement expression

Summary:
Do not automatically report self references of structs in statement expression
as warnings. Instead wait for uninitialized cfg analysis.
https://bugs.llvm.org/show_bug.cgi?id=42604

Reviewers: aaron.ballman, rsmith, nickdesaulniers

Reviewed By: aaron.ballman, nickdesaulniers

Subscribers: nathanchance, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D64678
------------------------------------------------------------------------

Added:
    cfe/branches/release_90/test/Sema/warn-uninitialized-statement-expression.c
      - copied unchanged from r367134, cfe/trunk/test/Sema/warn-uninitialized-statement-expression.c
Modified:
    cfe/branches/release_90/   (props changed)
    cfe/branches/release_90/lib/Sema/SemaDecl.cpp

Propchange: cfe/branches/release_90/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jul 26 13:47:20 2019
@@ -1,4 +1,4 @@
 /cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:366429,366448,366457,366474,366480,366483,366511,366670,366694,366699,367039,367103
+/cfe/trunk:366429,366448,366457,366474,366480,366483,366511,366670,366694,366699,367039,367103,367134
 /cfe/trunk/test:170344
 /cfe/trunk/test/SemaTemplate:126920

Modified: cfe/branches/release_90/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_90/lib/Sema/SemaDecl.cpp?rev=367150&r1=367149&r2=367150&view=diff
==============================================================================
--- cfe/branches/release_90/lib/Sema/SemaDecl.cpp (original)
+++ cfe/branches/release_90/lib/Sema/SemaDecl.cpp Fri Jul 26 13:47:20 2019
@@ -11527,9 +11527,12 @@ void Sema::AddInitializerToDecl(Decl *Re
   // Check for self-references within variable initializers.
   // Variables declared within a function/method body (except for references)
   // are handled by a dataflow analysis.
-  if (!VDecl->hasLocalStorage() || VDecl->getType()->isRecordType() ||
-      VDecl->getType()->isReferenceType()) {
-    CheckSelfReference(*this, RealDecl, Init, DirectInit);
+  // This is undefined behavior in C++, but valid in C.
+  if (getLangOpts().CPlusPlus) {
+    if (!VDecl->hasLocalStorage() || VDecl->getType()->isRecordType() ||
+        VDecl->getType()->isReferenceType()) {
+      CheckSelfReference(*this, RealDecl, Init, DirectInit);
+    }
   }
 
   // If the type changed, it means we had an incomplete type that was




More information about the llvm-branch-commits mailing list