]> granicus.if.org Git - clang/commitdiff
Functions can be lvalues in C++, but not modifiable lvalues
authorDouglas Gregor <dgregor@apple.com>
Wed, 22 Oct 2008 00:03:08 +0000 (00:03 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 22 Oct 2008 00:03:08 +0000 (00:03 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57941 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/Expr.cpp

index d957e33aa126b8daf30b8b4017d2e5cbef7b35f1..4fd8a24c8ada8458d81c195964ed00724a3fb0e6 100644 (file)
@@ -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;