diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/clang/AST/Expr.h | 27 | ||||
-rw-r--r-- | include/clang/Basic/DiagnosticSemaKinds.td | 2 | ||||
-rw-r--r-- | include/clang/Sema/Sema.h | 3 |
3 files changed, 27 insertions, 5 deletions
diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index 36644784c9..a17205c2b6 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -437,6 +437,22 @@ public: /// EvaluateAsLValue - Evaluate an expression to see if it's a lvalue. bool EvaluateAsAnyLValue(EvalResult &Result, const ASTContext &Ctx) const; + /// \brief Enumeration used to describe the kind of Null pointer constant + /// returned from \c isNullPointerConstant(). + enum NullPointerConstantKind { + /// \brief Expression is not a Null pointer constant. + NPCK_NotNull = 0, + + /// \brief Expression is a Null pointer constant built from a zero integer. + NPCK_ZeroInteger, + + /// \brief Expression is a C++0X nullptr. + NPCK_CXX0X_nullptr, + + /// \brief Expression is a GNU-style __null constant. + NPCK_GNUNull + }; + /// \brief Enumeration used to describe how \c isNullPointerConstant() /// should cope with value-dependent expressions. enum NullPointerConstantValueDependence { @@ -452,11 +468,12 @@ public: NPC_ValueDependentIsNotNull }; - /// isNullPointerConstant - C99 6.3.2.3p3 - Return true if this is either an - /// integer constant expression with the value zero, or if this is one that is - /// cast to void*. - bool isNullPointerConstant(ASTContext &Ctx, - NullPointerConstantValueDependence NPC) const; + /// isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to + /// a Null pointer constant. The return value can further distinguish the + /// kind of NULL pointer constant that was detected. + NullPointerConstantKind isNullPointerConstant( + ASTContext &Ctx, + NullPointerConstantValueDependence NPC) const; /// isOBJCGCCandidate - Return true if this expression may be used in a read/ /// write barrier. diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 7b28463349..9592cbb36f 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -3147,6 +3147,8 @@ def err_incomplete_type_used_in_type_trait_expr : Error< "incomplete type %0 used in type trait expression">; def err_expected_ident_or_lparen : Error<"expected identifier or '('">; +def err_typecheck_cond_incompatible_operands_null : Error< + "non-pointer operand type %0 incompatible with %select{NULL|nullptr}1">; } // End of general sema category. // inline asm. diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index 8d8cf09912..4e3173ab09 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -4774,6 +4774,9 @@ public: QualType FindCompositeObjCPointerType(Expr *&LHS, Expr *&RHS, SourceLocation questionLoc); + bool DiagnoseConditionalForNull(Expr *LHS, Expr *RHS, + SourceLocation QuestionLoc); + /// type checking for vector binary operators. QualType CheckVectorOperands(SourceLocation l, Expr *&lex, Expr *&rex); QualType CheckVectorCompareOperands(Expr *&lex, Expr *&rx, |