From ae8d467e75a4e72b19e1eca199bf93dfaab47acf Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Wed, 22 Oct 2008 00:03:08 +0000 Subject: [PATCH] Functions can be lvalues in C++, but not modifiable lvalues git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57941 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/Expr.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index d957e33aa1..4fd8a24c8a 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -422,7 +422,13 @@ Expr::isModifiableLvalueResult Expr::isModifiableLvalue(ASTContext &Ctx) const { isLvalueResult lvalResult = isLvalue(Ctx); switch (lvalResult) { - case LV_Valid: break; + case LV_Valid: + // C++ 3.10p11: Functions cannot be modified, but pointers to + // functions can be modifiable. + if (Ctx.getLangOptions().CPlusPlus && TR->isFunctionType()) + return MLV_NotObjectType; + break; + case LV_NotObjectType: return MLV_NotObjectType; case LV_IncompleteVoidType: return MLV_IncompleteVoidType; case LV_DuplicateVectorComponents: return MLV_DuplicateVectorComponents; -- 2.40.0