diff options
author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2009-05-10 18:38:11 +0000 |
---|---|---|
committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2009-05-10 18:38:11 +0000 |
commit | 576fd424dfe20c855bc9a8ac5dbac0c4d11fd9ef (patch) | |
tree | 848feaf684633a0718f55a24ed033b266438c4cb /clang/lib/Sema/SemaExpr.cpp | |
parent | 9a627e60cdb55b69f99671ae98a9ce3a3af6a92a (diff) | |
download | bcm5719-llvm-576fd424dfe20c855bc9a8ac5dbac0c4d11fd9ef.tar.gz bcm5719-llvm-576fd424dfe20c855bc9a8ac5dbac0c4d11fd9ef.zip |
Implement C++0x nullptr.
llvm-svn: 71405
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 063e0ec314d..d2e84c10e22 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -3811,6 +3811,20 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc, ImpCastExprToType(rex, lType); // promote the pointer to pointer return ResultTy; } + // C++ allows comparison of pointers with null pointer constants. + if (getLangOptions().CPlusPlus) { + if (lType->isPointerType() && RHSIsNull) { + ImpCastExprToType(rex, lType); + return ResultTy; + } + if (rType->isPointerType() && LHSIsNull) { + ImpCastExprToType(lex, rType); + return ResultTy; + } + // And comparison of nullptr_t with itself. + if (lType->isNullPtrType() && rType->isNullPtrType()) + return ResultTy; + } // Handle block pointer types. if (!isRelational && lType->isBlockPointerType() && rType->isBlockPointerType()) { QualType lpointee = lType->getAsBlockPointerType()->getPointeeType(); |