summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorAaron Ballman <aaron@aaronballman.com>2015-11-05 00:06:05 +0000
committerAaron Ballman <aaron@aaronballman.com>2015-11-05 00:06:05 +0000
commitb035cd7ea4d59e7e76412940351f693ec421e15e (patch)
treec0d9832c709e89fecc726701ae3d1fb226fd0608 /clang/lib/Sema/SemaExpr.cpp
parente5739981d5f4e3b9f62af10a8eb3b2ec18f807dc (diff)
downloadbcm5719-llvm-b035cd7ea4d59e7e76412940351f693ec421e15e.tar.gz
bcm5719-llvm-b035cd7ea4d59e7e76412940351f693ec421e15e.zip
The control expression for a _Generic selection expression should have
its type decayed and qualifiers stripped when determining which selection it matches. Fixes PR16340. llvm-svn: 252104
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 857925da99c..a4ca8a065cb 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -1354,11 +1354,13 @@ Sema::CreateGenericSelectionExpr(SourceLocation KeyLoc,
ArrayRef<Expr *> Exprs) {
unsigned NumAssocs = Types.size();
assert(NumAssocs == Exprs.size());
- if (ControllingExpr->getType()->isPlaceholderType()) {
- ExprResult result = CheckPlaceholderExpr(ControllingExpr);
- if (result.isInvalid()) return ExprError();
- ControllingExpr = result.get();
- }
+
+ // 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();
// The controlling expression is an unevaluated operand, so side effects are
// likely unintended.
OpenPOWER on IntegriCloud