Index: clang/lib/AST/ExprConstant.cpp =================================================================== --- clang/lib/AST/ExprConstant.cpp +++ clang/lib/AST/ExprConstant.cpp @@ -4184,18 +4184,27 @@ CallStackFrame Frame(Info, CallLoc, Callee, This, ArgValues.data()); + const CXXMethodDecl *MD = dyn_cast(Callee); + bool IsCopyOrMove = MD && MD->isCopyAssignmentOperator(); + IsCopyOrMove |= MD && MD->isMoveAssignmentOperator(); + + // We support explicit constructor calls as an MS extension. These can be + // constexpr by C++11 rules. + auto CD = dyn_cast_or_null(MD); + IsCopyOrMove |= CD && CD->isCopyConstructor(); + IsCopyOrMove |= CD && CD->isMoveConstructor(); + // For a trivial copy or move assignment, perform an APValue copy. This is // essential for unions, where the operations performed by the assignment // operator cannot be represented as statements. // // Skip this for non-union classes with no fields; in that case, the defaulted // copy/move does not actually read the object. - const CXXMethodDecl *MD = dyn_cast(Callee); - if (MD && MD->isDefaulted() && + if (MD && MD->isDefaulted() && IsCopyOrMove && (MD->getParent()->isUnion() || (MD->isTrivial() && hasFields(MD->getParent())))) { - assert(This && - (MD->isCopyAssignmentOperator() || MD->isMoveAssignmentOperator())); + assert(This); + LValue RHS; RHS.setFrom(Info.Ctx, ArgValues[0]); APValue RHSValue; Index: clang/test/CodeGenCXX/constructor-direct-call.cpp =================================================================== --- clang/test/CodeGenCXX/constructor-direct-call.cpp +++ clang/test/CodeGenCXX/constructor-direct-call.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -triple i686-pc-mingw32 -fms-extensions -Wmicrosoft %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -triple i686-pc-mingw32 -fms-extensions -Wmicrosoft %s -emit-llvm -o - -std=gnu++11| FileCheck %s class Test1 { public: