A little more lambda capture initialization diagnostics cleanup

llvm-svn: 150589
This commit is contained in:
Douglas Gregor 2012-02-15 17:05:32 +00:00
parent 19666fb1aa
commit 02267a8e48
2 changed files with 12 additions and 5 deletions

View File

@ -1141,24 +1141,24 @@ def err_temp_copy_no_viable : Error<
"no viable constructor %select{copying variable|copying parameter|" "no viable constructor %select{copying variable|copying parameter|"
"returning object|throwing object|copying member subobject|copying array " "returning object|throwing object|copying member subobject|copying array "
"element|allocating object|copying temporary|initializing base subobject|" "element|allocating object|copying temporary|initializing base subobject|"
"initializing vector element}0 of type %1">; "initializing vector element|capturing value}0 of type %1">;
def ext_rvalue_to_reference_temp_copy_no_viable : ExtWarn< def ext_rvalue_to_reference_temp_copy_no_viable : ExtWarn<
"no viable constructor %select{copying variable|copying parameter|" "no viable constructor %select{copying variable|copying parameter|"
"returning object|throwing object|copying member subobject|copying array " "returning object|throwing object|copying member subobject|copying array "
"element|allocating object|copying temporary|initializing base subobject|" "element|allocating object|copying temporary|initializing base subobject|"
"initializing vector element}0 of type %1; C++98 requires a copy " "initializing vector element|capturing value}0 of type %1; C++98 requires a copy "
"constructor when binding a reference to a temporary">, "constructor when binding a reference to a temporary">,
InGroup<BindToTemporaryCopy>; InGroup<BindToTemporaryCopy>;
def err_temp_copy_ambiguous : Error< def err_temp_copy_ambiguous : Error<
"ambiguous constructor call when %select{copying variable|copying " "ambiguous constructor call when %select{copying variable|copying "
"parameter|returning object|throwing object|copying member subobject|copying " "parameter|returning object|throwing object|copying member subobject|copying "
"array element|allocating object|copying temporary|initializing base subobject|" "array element|allocating object|copying temporary|initializing base subobject|"
"initializing vector element}0 of type %1">; "initializing vector element|capturing value}0 of type %1">;
def err_temp_copy_deleted : Error< def err_temp_copy_deleted : Error<
"%select{copying variable|copying parameter|returning object|throwing " "%select{copying variable|copying parameter|returning object|throwing "
"object|copying member subobject|copying array element|allocating object|" "object|copying member subobject|copying array element|allocating object|"
"copying temporary|initializing base subobject|initializing vector element}0 " "copying temporary|initializing base subobject|initializing vector element}0 "
"of type %1 invokes deleted constructor">; "of type %1 invokes deleted constructor|capturing value">;
def err_temp_copy_incomplete : Error< def err_temp_copy_incomplete : Error<
"copying a temporary object of incomplete type %0">; "copying a temporary object of incomplete type %0">;
def warn_cxx98_compat_temp_copy : Warning< def warn_cxx98_compat_temp_copy : Warning<

View File

@ -8,11 +8,18 @@ public:
void foo() const; void foo() const;
}; };
void capture_by_copy(NonCopyable nc, NonCopyable &ncr) { class NonConstCopy {
public:
NonConstCopy(NonConstCopy&); // expected-note{{would lose const}}
};
void capture_by_copy(NonCopyable nc, NonCopyable &ncr, const NonConstCopy nco) {
(void)[nc] { }; // expected-error{{capture of variable 'nc' as type 'NonCopyable' calls private copy constructor}} (void)[nc] { }; // expected-error{{capture of variable 'nc' as type 'NonCopyable' calls private copy constructor}}
(void)[=] { (void)[=] {
ncr.foo(); // expected-error{{capture of variable 'ncr' as type 'NonCopyable' calls private copy constructor}} ncr.foo(); // expected-error{{capture of variable 'ncr' as type 'NonCopyable' calls private copy constructor}}
}(); }();
[nco] {}(); // expected-error{{no matching constructor for initialization of 'const NonConstCopy'}}
} }
struct NonTrivial { struct NonTrivial {