]> granicus.if.org Git - clang/commitdiff
Don't intentionally try to ignore the value of a scalar expression when we
authorEli Friedman <eli.friedman@gmail.com>
Thu, 3 Jun 2010 19:58:07 +0000 (19:58 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Thu, 3 Jun 2010 19:58:07 +0000 (19:58 +0000)
actually care about it. Fixes PR7291.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105404 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGClass.cpp
test/CodeGenCXX/member-init-assignment.cpp [new file with mode: 0644]

index bebea549f965ad19f207b0b3ea961685aa68fb97..348f85b32fd9ed05fb2aa2eea9b67f8f52025fa3 100644 (file)
@@ -467,7 +467,7 @@ static void EmitMemberInitializer(CodeGenFunction &CGF,
   } else if (FieldType->isArrayType() && !MemberInit->getInit()) {
     CGF.EmitNullInitialization(LHS.getAddress(), Field->getType());
   } else if (!CGF.hasAggregateLLVMType(Field->getType())) {
-    RHS = RValue::get(CGF.EmitScalarExpr(MemberInit->getInit(), true));
+    RHS = RValue::get(CGF.EmitScalarExpr(MemberInit->getInit()));
     CGF.EmitStoreThroughLValue(RHS, LHS, FieldType);
   } else if (MemberInit->getInit()->getType()->isAnyComplexType()) {
     CGF.EmitComplexExprIntoAddr(MemberInit->getInit(), LHS.getAddress(),
diff --git a/test/CodeGenCXX/member-init-assignment.cpp b/test/CodeGenCXX/member-init-assignment.cpp
new file mode 100644 (file)
index 0000000..c23fe2b
--- /dev/null
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -emit-llvm-only -verify
+// PR7291
+
+struct Foo {
+  unsigned file_id;
+
+  Foo(unsigned arg);
+};
+
+Foo::Foo(unsigned arg) : file_id(arg = 42)
+{ }
+