summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2011-08-29 23:55:37 +0000
committerJohn McCall <rjmccall@apple.com>2011-08-29 23:55:37 +0000
commit0562caaad6d91e91bfa2c900409f197c85f393e2 (patch)
tree92a331c19b7e7c1fbd6d078a0e83a66203f47393 /clang/lib
parentccdceb5aacba16e9d37432ec2148a16c05ee40d9 (diff)
downloadbcm5719-llvm-0562caaad6d91e91bfa2c900409f197c85f393e2.tar.gz
bcm5719-llvm-0562caaad6d91e91bfa2c900409f197c85f393e2.zip
Update the comment on the default-argument conversion fix; thanks to
Johannes Schaub for talking me around to sense. llvm-svn: 138784
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 6327ee71db1..a927e13cfdc 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -444,12 +444,16 @@ ExprResult Sema::DefaultArgumentPromotion(Expr *E) {
E = ImpCastExprToType(E, Context.DoubleTy, CK_FloatingCast).take();
// C++ performs lvalue-to-rvalue conversion as a default argument
- // promotion. If we still have a gl-value after usual unary
- // conversion, we must have an l-value of class type, so we need to
- // initialize a temporary. For compatibility reasons, however, we
- // don't want to do this in unevaluated contexts; otherwise we
- // reject metaprograms which work by passing uncopyable l-values to
- // variadic functions.
+ // promotion, even on class types, but note:
+ // C++11 [conv.lval]p2:
+ // When an lvalue-to-rvalue conversion occurs in an unevaluated
+ // operand or a subexpression thereof the value contained in the
+ // referenced object is not accessed. Otherwise, if the glvalue
+ // 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() &&
ExprEvalContexts.back().Context != Unevaluated) {
ExprResult Temp = PerformCopyInitialization(
OpenPOWER on IntegriCloud