summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-01-06 22:50:31 +0000
committerChris Lattner <sabre@nondot.org>2008-01-06 22:50:31 +0000
commit4d3b0f579ca500edf427ee77fafacbf44cfba1a3 (patch)
treee975e8e8fa2ed24b2afdc23f0116cb57cce950cb
parente2949f42d3485033230727889a619c5f5b7984e0 (diff)
downloadbcm5719-llvm-4d3b0f579ca500edf427ee77fafacbf44cfba1a3.tar.gz
bcm5719-llvm-4d3b0f579ca500edf427ee77fafacbf44cfba1a3.zip
rearrange some code.
llvm-svn: 45666
-rw-r--r--clang/Sema/SemaExpr.cpp27
1 files changed, 16 insertions, 11 deletions
diff --git a/clang/Sema/SemaExpr.cpp b/clang/Sema/SemaExpr.cpp
index dcbfe78a41f..71d1b60e14a 100644
--- a/clang/Sema/SemaExpr.cpp
+++ b/clang/Sema/SemaExpr.cpp
@@ -789,16 +789,8 @@ inline QualType Sema::CheckConditionalOperands( // C99 6.5.15
if (lexT->isVoidType() && rexT->isVoidType())
return lexT.getUnqualifiedType();
- // C99 6.5.15p6 - "if one operand is a null pointer constant, the result has
- // the type of the other operand."
- if (lexT->isPointerType() && rex->isNullPointerConstant(Context)) {
- promoteExprToType(rex, lexT); // promote the null to a pointer.
- return lexT;
- }
- if (rexT->isPointerType() && lex->isNullPointerConstant(Context)) {
- promoteExprToType(lex, rexT); // promote the null to a pointer.
- return rexT;
- }
+ // Handle the case where both operands are pointers before we handle null
+ // pointer constants in case both operands are null pointer constants.
if (const PointerType *LHSPT = lexT->getAsPointerType()) { // C99 6.5.15p3,6
if (const PointerType *RHSPT = rexT->getAsPointerType()) {
// get the "pointed to" types
@@ -825,10 +817,23 @@ inline QualType Sema::CheckConditionalOperands( // C99 6.5.15
// differently qualified versions of compatible types, the result type is
// a pointer to an appropriately qualified version of the *composite*
// type.
- return lexT; // FIXME: Need to return the composite type.
+ // FIXME: Need to return the composite type.
+ return lexT;
}
}
+ // C99 6.5.15p6 - "if one operand is a null pointer constant, the result has
+ // the type of the other operand."
+ if (lexT->isPointerType() && rex->isNullPointerConstant(Context)) {
+ promoteExprToType(rex, lexT); // promote the null to a pointer.
+ return lexT;
+ }
+
+ if (rexT->isPointerType() && lex->isNullPointerConstant(Context)) {
+ promoteExprToType(lex, rexT); // promote the null to a pointer.
+ return rexT;
+ }
+
// Otherwise, the operands are not compatible.
Diag(questionLoc, diag::err_typecheck_cond_incompatible_operands,
lexT.getAsString(), rexT.getAsString(),
OpenPOWER on IntegriCloud