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: