tbaeder created this revision. tbaeder added reviewers: aaron.ballman, erichkeane, shafik, cor3ntin. Herald added a project: All. tbaeder requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D155552 Files: clang/lib/AST/Interp/ByteCodeExprGen.cpp clang/lib/AST/Interp/ByteCodeExprGen.h clang/test/AST/Interp/literals.cpp Index: clang/test/AST/Interp/literals.cpp =================================================================== --- clang/test/AST/Interp/literals.cpp +++ clang/test/AST/Interp/literals.cpp @@ -12,6 +12,7 @@ static_assert(true, ""); static_assert(false, ""); // expected-error{{failed}} ref-error{{failed}} static_assert(nullptr == nullptr, ""); +static_assert(__null == __null, ""); static_assert(1 == 1, ""); static_assert(1 == 3, ""); // expected-error{{failed}} ref-error{{failed}} @@ -928,6 +929,7 @@ /// Ignored MaterializeTemporaryExpr. struct B{ const int &a; }; (B{12}, 0); + __null; return 0; } Index: clang/lib/AST/Interp/ByteCodeExprGen.h =================================================================== --- clang/lib/AST/Interp/ByteCodeExprGen.h +++ clang/lib/AST/Interp/ByteCodeExprGen.h @@ -71,6 +71,7 @@ bool VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *E); bool VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *E); bool VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *E); + bool VisitGNUNullExpr(const GNUNullExpr *E); bool VisitCXXThisExpr(const CXXThisExpr *E); bool VisitUnaryOperator(const UnaryOperator *E); bool VisitDeclRefExpr(const DeclRefExpr *E); Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp =================================================================== --- clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -2033,6 +2033,17 @@ return this->emitNullPtr(E); } +template <class Emitter> +bool ByteCodeExprGen<Emitter>::VisitGNUNullExpr(const GNUNullExpr *E) { + if (DiscardResult) + return true; + + assert(E->getType()->isIntegerType()); + + PrimType T = classifyPrim(E->getType()); + return this->emitZero(T, E); +} + template <class Emitter> bool ByteCodeExprGen<Emitter>::VisitCXXThisExpr(const CXXThisExpr *E) { if (DiscardResult)
Index: clang/test/AST/Interp/literals.cpp =================================================================== --- clang/test/AST/Interp/literals.cpp +++ clang/test/AST/Interp/literals.cpp @@ -12,6 +12,7 @@ static_assert(true, ""); static_assert(false, ""); // expected-error{{failed}} ref-error{{failed}} static_assert(nullptr == nullptr, ""); +static_assert(__null == __null, ""); static_assert(1 == 1, ""); static_assert(1 == 3, ""); // expected-error{{failed}} ref-error{{failed}} @@ -928,6 +929,7 @@ /// Ignored MaterializeTemporaryExpr. struct B{ const int &a; }; (B{12}, 0); + __null; return 0; } Index: clang/lib/AST/Interp/ByteCodeExprGen.h =================================================================== --- clang/lib/AST/Interp/ByteCodeExprGen.h +++ clang/lib/AST/Interp/ByteCodeExprGen.h @@ -71,6 +71,7 @@ bool VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *E); bool VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *E); bool VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *E); + bool VisitGNUNullExpr(const GNUNullExpr *E); bool VisitCXXThisExpr(const CXXThisExpr *E); bool VisitUnaryOperator(const UnaryOperator *E); bool VisitDeclRefExpr(const DeclRefExpr *E); Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp =================================================================== --- clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -2033,6 +2033,17 @@ return this->emitNullPtr(E); } +template <class Emitter> +bool ByteCodeExprGen<Emitter>::VisitGNUNullExpr(const GNUNullExpr *E) { + if (DiscardResult) + return true; + + assert(E->getType()->isIntegerType()); + + PrimType T = classifyPrim(E->getType()); + return this->emitZero(T, E); +} + template <class Emitter> bool ByteCodeExprGen<Emitter>::VisitCXXThisExpr(const CXXThisExpr *E) { if (DiscardResult)
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits