From: Douglas Gregor Date: Wed, 22 Oct 2008 00:03:08 +0000 (+0000) Subject: Functions can be lvalues in C++, but not modifiable lvalues X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ae8d467e75a4e72b19e1eca199bf93dfaab47acf;p=clang 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 --- 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;