]> granicus.if.org Git - clang/commitdiff
fix PR4067: [Linux kernel] cannot aggregate codegen stmtexpr as lvalue
authorChris Lattner <sabre@nondot.org>
Sat, 25 Apr 2009 19:35:26 +0000 (19:35 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 25 Apr 2009 19:35:26 +0000 (19:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70067 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExpr.cpp
lib/CodeGen/CGExprAgg.cpp
lib/CodeGen/CodeGenFunction.h
test/CodeGen/exprs.c

index c49592eae8ea8498f680a1f96920235e56e6f08e..86993fbe150bb8283e58167252861d9bf30c7d7d 100644 (file)
@@ -168,8 +168,10 @@ LValue CodeGenFunction::EmitLValue(const Expr *E) {
   case Expr::ObjCKVCRefExprClass:
     return EmitObjCKVCRefLValue(cast<ObjCKVCRefExpr>(E));
   case Expr::ObjCSuperExprClass:
-    return EmitObjCSuperExpr(cast<ObjCSuperExpr>(E));
+    return EmitObjCSuperExprLValue(cast<ObjCSuperExpr>(E));
 
+  case Expr::StmtExprClass:
+    return EmitStmtExprLValue(cast<StmtExpr>(E));
   case Expr::UnaryOperatorClass: 
     return EmitUnaryOpLValue(cast<UnaryOperator>(E));
   case Expr::ArraySubscriptExprClass:
@@ -1195,10 +1197,21 @@ CodeGenFunction::EmitObjCKVCRefLValue(const ObjCKVCRefExpr *E) {
 }
 
 LValue
-CodeGenFunction::EmitObjCSuperExpr(const ObjCSuperExpr *E) {
+CodeGenFunction::EmitObjCSuperExprLValue(const ObjCSuperExpr *E) {
   return EmitUnsupportedLValue(E, "use of super");
 }
 
+LValue CodeGenFunction::EmitStmtExprLValue(const StmtExpr *E) {
+  
+  // Can only get l-value for message expression returning aggregate type
+  RValue RV = EmitAnyExprToTemp(E);
+  // FIXME: can this be volatile?
+  return LValue::MakeAddr(RV.getAggregateAddr(),
+                          E->getType().getCVRQualifiers(),
+                          getContext().getObjCGCAttrKind(E->getType()));
+}
+
+
 RValue CodeGenFunction::EmitCallExpr(llvm::Value *Callee, QualType CalleeType, 
                                      CallExpr::const_arg_iterator ArgBeg,
                                      CallExpr::const_arg_iterator ArgEnd,
index 2e45f2017b422717fc5d45736ca55e729b2139e9..a74741290b08ddbc58aa7bc5ca5f6bd648f6f560 100644 (file)
@@ -78,8 +78,6 @@ public:
   }
   
   // Operators.
-  //  case Expr::UnaryOperatorClass:
-  //  case Expr::CastExprClass: 
   void VisitCStyleCastExpr(CStyleCastExpr *E);
   void VisitImplicitCastExpr(ImplicitCastExpr *E);
   void VisitCallExpr(const CallExpr *E);
index 2cad46ed0177ce58b6844969c54ac103bafca0a9..9fc59527ce79cccd55eb1b1f4a4b12782ec1dfb7 100644 (file)
@@ -645,7 +645,8 @@ public:
   LValue EmitObjCIvarRefLValue(const ObjCIvarRefExpr *E);
   LValue EmitObjCPropertyRefLValue(const ObjCPropertyRefExpr *E);
   LValue EmitObjCKVCRefLValue(const ObjCKVCRefExpr *E);
-  LValue EmitObjCSuperExpr(const ObjCSuperExpr *E);
+  LValue EmitObjCSuperExprLValue(const ObjCSuperExpr *E);
+  LValue EmitStmtExprLValue(const StmtExpr *E);
 
   //===--------------------------------------------------------------------===//
   //                         Scalar Expression Emission
index f80ee4195803fd821d6ab320ee8468142ad6a179..ad3e4e095686242840a787ecf9a39739136c4723 100644 (file)
@@ -99,3 +99,8 @@ int f6(int a0, struct s6 a1, struct s6 a2) {
 void f7() {
   __func__;
 }
+
+// PR4067
+int f8() {
+  return ({ foo(); }).Y;
+}