From: Eli Friedman Date: Thu, 3 Jun 2010 19:58:07 +0000 (+0000) Subject: Don't intentionally try to ignore the value of a scalar expression when we X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0b29227012aacb1ae42277b0a63d28acb1b35270;p=clang Don't intentionally try to ignore the value of a scalar expression when we actually care about it. Fixes PR7291. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105404 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGClass.cpp b/lib/CodeGen/CGClass.cpp index bebea549f9..348f85b32f 100644 --- a/lib/CodeGen/CGClass.cpp +++ b/lib/CodeGen/CGClass.cpp @@ -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 index 0000000000..c23fe2b9c5 --- /dev/null +++ b/test/CodeGenCXX/member-init-assignment.cpp @@ -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) +{ } +