Update the comment on the default-argument conversion fix; thanks to

Johannes Schaub for talking me around to sense.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138784 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
John McCall 2011-08-29 23:55:37 +00:00
Родитель 1335cf086f
Коммит 709bca84cf
1 изменённых файлов: 10 добавлений и 6 удалений

Просмотреть файл

@ -444,12 +444,16 @@ ExprResult Sema::DefaultArgumentPromotion(Expr *E) {
E = ImpCastExprToType(E, Context.DoubleTy, CK_FloatingCast).take(); E = ImpCastExprToType(E, Context.DoubleTy, CK_FloatingCast).take();
// C++ performs lvalue-to-rvalue conversion as a default argument // C++ performs lvalue-to-rvalue conversion as a default argument
// promotion. If we still have a gl-value after usual unary // promotion, even on class types, but note:
// conversion, we must have an l-value of class type, so we need to // C++11 [conv.lval]p2:
// initialize a temporary. For compatibility reasons, however, we // When an lvalue-to-rvalue conversion occurs in an unevaluated
// don't want to do this in unevaluated contexts; otherwise we // operand or a subexpression thereof the value contained in the
// reject metaprograms which work by passing uncopyable l-values to // referenced object is not accessed. Otherwise, if the glvalue
// variadic functions. // has a class type, the conversion copy-initializes a temporary
// of type T from the glvalue and the result of the conversion
// is a prvalue for the temporary.
// FIXME: add some way to gate this entire thing for correctness in
// potentially potentially evaluated contexts.
if (getLangOptions().CPlusPlus && E->isGLValue() && if (getLangOptions().CPlusPlus && E->isGLValue() &&
ExprEvalContexts.back().Context != Unevaluated) { ExprEvalContexts.back().Context != Unevaluated) {
ExprResult Temp = PerformCopyInitialization( ExprResult Temp = PerformCopyInitialization(