]> granicus.if.org Git - clang/commitdiff
Amends r252104 to evaluate the controlling expression in an unevaluated context....
authorAaron Ballman <aaron@aaronballman.com>
Tue, 23 Feb 2016 18:55:15 +0000 (18:55 +0000)
committerAaron Ballman <aaron@aaronballman.com>
Tue, 23 Feb 2016 18:55:15 +0000 (18:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@261669 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/Sema/generic-selection.c

index bfbca298ce87e90ef84b03e504aa6a3ce221ee89..ee9e646e24ce4955de64ec34574e1806b59e01ff 100644 (file)
@@ -1373,10 +1373,13 @@ Sema::CreateGenericSelectionExpr(SourceLocation KeyLoc,
 
   // 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.
index 0563ec0f4fc002ba9636a177148afe9c7140d662..5c02005d0fa80a87980f14048a5ca7def5fe70ee 100644 (file)
@@ -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);
 }