[llvm-branch-commits] [cfe-branch] r261684 - Merging r261669:

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Feb 23 13:20:40 PST 2016


Author: hans
Date: Tue Feb 23 15:20:39 2016
New Revision: 261684

URL: http://llvm.org/viewvc/llvm-project?rev=261684&view=rev
Log:
Merging r261669:
------------------------------------------------------------------------
r261669 | aaronballman | 2016-02-23 10:55:15 -0800 (Tue, 23 Feb 2016) | 1 line

Amends r252104 to evaluate the controlling expression in an unevaluated context. This eliminates false-positive diagnostics about null pointer dereferences (etc) in the controlling expression.
------------------------------------------------------------------------

Modified:
    cfe/branches/release_38/   (props changed)
    cfe/branches/release_38/lib/Sema/SemaExpr.cpp
    cfe/branches/release_38/test/Sema/generic-selection.c

Propchange: cfe/branches/release_38/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Feb 23 15:20:39 2016
@@ -1,4 +1,4 @@
 /cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:257652,257695,257710,257763,257831,257838,257853,257861,257869-257871,257947,258110,258396,259183,259260,259598,259874,259931,260370,260616,260637,260851,261080,261209,261309,261422
+/cfe/trunk:257652,257695,257710,257763,257831,257838,257853,257861,257869-257871,257947,258110,258396,259183,259260,259598,259874,259931,260370,260616,260637,260851,261080,261209,261309,261422,261669
 /cfe/trunk/test:170344
 /cfe/trunk/test/SemaTemplate:126920

Modified: cfe/branches/release_38/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_38/lib/Sema/SemaExpr.cpp?rev=261684&r1=261683&r2=261684&view=diff
==============================================================================
--- cfe/branches/release_38/lib/Sema/SemaExpr.cpp (original)
+++ cfe/branches/release_38/lib/Sema/SemaExpr.cpp Tue Feb 23 15:20:39 2016
@@ -1365,10 +1365,13 @@ Sema::CreateGenericSelectionExpr(SourceL
 
   // Decay and strip qualifiers for the controlling expression type, and handle
   // placeholder type replacement. See committee discussion from WG14 DR423.
-  ExprResult R = DefaultFunctionArrayLvalueConversion(ControllingExpr);
-  if (R.isInvalid())
-    return ExprError();
-  ControllingExpr = R.get();
+  {
+    EnterExpressionEvaluationContext Unevaluated(*this, Sema::Unevaluated);
+    ExprResult R = DefaultFunctionArrayLvalueConversion(ControllingExpr);
+    if (R.isInvalid())
+      return ExprError();
+    ControllingExpr = R.get();
+  }
 
   // The controlling expression is an unevaluated operand, so side effects are
   // likely unintended.

Modified: cfe/branches/release_38/test/Sema/generic-selection.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_38/test/Sema/generic-selection.c?rev=261684&r1=261683&r2=261684&view=diff
==============================================================================
--- cfe/branches/release_38/test/Sema/generic-selection.c (original)
+++ cfe/branches/release_38/test/Sema/generic-selection.c Tue Feb 23 15:20:39 2016
@@ -31,4 +31,8 @@ void foo(int n) {
 
   const int i = 12;
   int a9[_Generic(i, int: 1, default: 2) == 1 ? 1 : -1];
+
+  // This is expected to not trigger any diagnostics because the controlling
+  // expression is not evaluated.
+  (void)_Generic(*(int *)0, int: 1);
 }




More information about the llvm-branch-commits mailing list