summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaInit.h
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-04-18 07:40:54 +0000
committerDouglas Gregor <dgregor@apple.com>2010-04-18 07:40:54 +0000
commitc9cd64eee393798c413ba20392c09c78c2a90ad5 (patch)
treec891b19abaef4bfd903053d9fe815cb88932455d /clang/lib/Sema/SemaInit.h
parent554a39889b6d80e109dc33d1e4b7cb12e7caee4b (diff)
downloadbcm5719-llvm-c9cd64eee393798c413ba20392c09c78c2a90ad5.tar.gz
bcm5719-llvm-c9cd64eee393798c413ba20392c09c78c2a90ad5.zip
In C++98/03, when binding a reference to an rvalue of
reference-compatible type, the implementation is permitted to make a copy of the rvalue (or many such copies, even). However, even though we don't make that copy, we are required to check for the presence of a suitable copy constructor. With this change, we do. Note that in C++0x we are not allowed to make these copies, so we test both dialects separately. Also note the FIXME in one of the C++03 tests, where we are not instantiating default function arguments for the copy constructor we pick (but do not call). The fix is obvious; eliminating the infinite recursion it causes is not. Will address that next. llvm-svn: 101704
Diffstat (limited to 'clang/lib/Sema/SemaInit.h')
-rw-r--r--clang/lib/Sema/SemaInit.h23
1 files changed, 21 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaInit.h b/clang/lib/Sema/SemaInit.h
index 65ee42042c0..db987ec2961 100644
--- a/clang/lib/Sema/SemaInit.h
+++ b/clang/lib/Sema/SemaInit.h
@@ -416,6 +416,10 @@ public:
SK_BindReference,
/// \brief Reference binding to a temporary.
SK_BindReferenceToTemporary,
+ /// \brief An optional copy of a temporary object to another
+ /// temporary object, which is permitted (but not required) by
+ /// C++98/03 but not C++0x.
+ SK_ExtraneousCopyToTemporary,
/// \brief Perform a user-defined conversion, either via a conversion
/// function or via a constructor.
SK_UserConversion,
@@ -629,11 +633,26 @@ public:
/// \brief Add a new step binding a reference to an object.
///
- /// \param BindingTemporary true if we are binding a reference to a temporary
+ /// \param BindingTemporary True if we are binding a reference to a temporary
/// object (thereby extending its lifetime); false if we are binding to an
/// lvalue or an lvalue treated as an rvalue.
+ ///
+ /// \param UnnecessaryCopy True if we should check for a copy
+ /// constructor for a completely unnecessary but
void AddReferenceBindingStep(QualType T, bool BindingTemporary);
-
+
+ /// \brief Add a new step that makes an extraneous copy of the input
+ /// to a temporary of the same class type.
+ ///
+ /// This extraneous copy only occurs during reference binding in
+ /// C++98/03, where we are permitted (but not required) to introduce
+ /// an extra copy. At a bare minimum, we must check that we could
+ /// call the copy constructor, and produce a diagnostic if the copy
+ /// constructor is inaccessible or no copy constructor matches.
+ //
+ /// \param T The type of the temporary being created.
+ void AddExtraneousCopyToTemporary(QualType T);
+
/// \brief Add a new step invoking a conversion function, which is either
/// a constructor or a conversion function.
void AddUserConversionStep(FunctionDecl *Function,
OpenPOWER on IntegriCloud