aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-10-12 07:14:40 +0000
committerJohn McCall <rjmccall@apple.com>2010-10-12 07:14:40 +0000
commitcf2e5063ae7e7ed3f8d86bb426b2208e242128ab (patch)
treea6b13804b9eb96acb8ab82ae7e976020a4c1efa7 /lib/Sema/SemaExpr.cpp
parentf9c5afb8df90d2711fdb0d3699aba99f1db0b848 (diff)
C's comma operator performs lvalue conversion on both its operands;
require them to have complete types. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116297 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r--lib/Sema/SemaExpr.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 52ab62be02..514d9ba3f2 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -6164,13 +6164,18 @@ QualType Sema::CheckAssignmentOperands(Expr *LHS, Expr *&RHS,
QualType Sema::CheckCommaOperands(Expr *LHS, Expr *&RHS, SourceLocation Loc) {
DiagnoseUnusedExprResult(LHS);
- // Comma performs lvalue conversion (C99 6.3.2.1), but not unary conversions.
- // C++ does not perform this conversion (C++ [expr.comma]p1).
- if (!getLangOptions().CPlusPlus)
- DefaultFunctionArrayLvalueConversion(RHS);
+ // C's comma performs lvalue conversion (C99 6.3.2.1) on both its
+ // operands, but not unary promotions.
+ // C++'s comma does not do any conversions at all (C++ [expr.comma]p1).
+ if (!getLangOptions().CPlusPlus) {
+ DefaultFunctionArrayLvalueConversion(LHS);
+ if (!LHS->getType()->isVoidType())
+ RequireCompleteType(Loc, LHS->getType(), diag::err_incomplete_type);
- // FIXME: Check that RHS type is complete in C mode (it's legal for it to be
- // incomplete in C++).
+ DefaultFunctionArrayLvalueConversion(RHS);
+ if (!RHS->getType()->isVoidType())
+ RequireCompleteType(Loc, RHS->getType(), diag::err_incomplete_type);
+ }
return RHS->getType();
}