From b633c4ee622df81d4572ef57dac54ebed69bb9bf Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Tue, 1 Sep 2009 20:37:18 +0000 Subject: [PATCH] Add a CK_FunctionToPointerDecay cast kind. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80719 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/Expr.h | 3 +++ lib/AST/StmtDumper.cpp | 3 +++ lib/Sema/SemaExpr.cpp | 3 ++- lib/Sema/SemaExprCXX.cpp | 2 +- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index 793eb1edc6..750b72cbcf 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -1347,6 +1347,9 @@ public: /// CK_ArrayToPointerDecay - Array to pointer decay. CK_ArrayToPointerDecay, + // CK_FunctionToPointerDecay - Function to pointer decay. + CK_FunctionToPointerDecay, + /// CK_NullToMemberPointer - Null pointer to member pointer. CK_NullToMemberPointer, diff --git a/lib/AST/StmtDumper.cpp b/lib/AST/StmtDumper.cpp index 720188377d..7d8d64cb63 100644 --- a/lib/AST/StmtDumper.cpp +++ b/lib/AST/StmtDumper.cpp @@ -324,6 +324,9 @@ void StmtDumper::VisitCastExpr(CastExpr *Node) { case CastExpr::CK_ArrayToPointerDecay: fprintf(F, ""); break; + case CastExpr::CK_FunctionToPointerDecay: + fprintf(F, ""); + break; case CastExpr::CK_NullToMemberPointer: fprintf(F, ""); break; diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index d272be9765..c01097e363 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -196,7 +196,8 @@ void Sema::DefaultFunctionArrayConversion(Expr *&E) { assert(!Ty.isNull() && "DefaultFunctionArrayConversion - missing type"); if (Ty->isFunctionType()) - ImpCastExprToType(E, Context.getPointerType(Ty)); + ImpCastExprToType(E, Context.getPointerType(Ty), + CastExpr::CK_FunctionToPointerDecay); else if (Ty->isArrayType()) { // In C90 mode, arrays only promote to pointers if the array expression is // an lvalue. The relevant legalese is C90 6.2.2.1p3: "an lvalue that has diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 35938260c6..0dc4b8d180 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -1016,7 +1016,7 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType, FromType = From->getType(); } FromType = Context.getPointerType(FromType); - ImpCastExprToType(From, FromType); + ImpCastExprToType(From, FromType, CastExpr::CK_FunctionToPointerDecay); break; default: