* [C++ patch] Fix c++/PR61133, implement the resolution of DR1760
@ 2014-05-09 23:02 Ville Voutilainen
2014-05-21 17:43 ` Jason Merrill
0 siblings, 1 reply; 2+ messages in thread
From: Ville Voutilainen @ 2014-05-09 23:02 UTC (permalink / raw)
To: Jason Merrill, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 57 bytes --]
I guess the subject says it all. Tested on Linux x86-64.
[-- Attachment #2: pr61133.diff --]
[-- Type: text/plain, Size: 2719 bytes --]
diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c
index 3ce9ebb..bb6014b 100644
--- a/gcc/cp/lambda.c
+++ b/gcc/cp/lambda.c
@@ -367,10 +367,7 @@ build_capture_proxy (tree member)
object = TREE_OPERAND (object, 0);
/* Remove the __ inserted by add_capture. */
- if (DECL_NORMAL_CAPTURE_P (member))
- name = get_identifier (IDENTIFIER_POINTER (DECL_NAME (member)) + 2);
- else
- name = DECL_NAME (member);
+ name = get_identifier (IDENTIFIER_POINTER (DECL_NAME (member)) + 2);
type = lambda_proxy_type (object);
@@ -500,17 +497,11 @@ add_capture (tree lambda, tree id, tree orig_init, bool by_reference_p,
won't find the field with name lookup. We can't just leave the name
unset because template instantiation uses the name to find
instantiated fields. */
- if (!explicit_init_p)
- {
- buf = (char *) alloca (IDENTIFIER_LENGTH (id) + 3);
- buf[1] = buf[0] = '_';
- memcpy (buf + 2, IDENTIFIER_POINTER (id),
- IDENTIFIER_LENGTH (id) + 1);
- name = get_identifier (buf);
- }
- else
- /* But captures with explicit initializers are named. */
- name = id;
+ buf = (char *) alloca (IDENTIFIER_LENGTH (id) + 3);
+ buf[1] = buf[0] = '_';
+ memcpy (buf + 2, IDENTIFIER_POINTER (id),
+ IDENTIFIER_LENGTH (id) + 1);
+ name = get_identifier (buf);
/* If TREE_TYPE isn't set, we're still in the introducer, so check
for duplicates. */
diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-init6.C b/gcc/testsuite/g++.dg/cpp1y/lambda-init6.C
index 2b82bca..e253000 100644
--- a/gcc/testsuite/g++.dg/cpp1y/lambda-init6.C
+++ b/gcc/testsuite/g++.dg/cpp1y/lambda-init6.C
@@ -1,12 +1,10 @@
-// Test that simple captures are not named in the closure type, but
-// initialized captures are named.
+// Test that captures are not named in the closure type.
// { dg-do compile { target c++1y } }
int main()
{
int i;
auto lam = [i,j=42]{};
- lam.j;
- lam.j.foo; // { dg-error "::j" }
+ lam.j; // { dg-error "no member" }
lam.i; // { dg-error "no member" }
}
diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-init8.C b/gcc/testsuite/g++.dg/cpp1y/lambda-init8.C
new file mode 100644
index 0000000..478b1c6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/lambda-init8.C
@@ -0,0 +1,26 @@
+// DR1760: "no additional copy and destruction is performed"
+// { dg-do run { target c++1y } }
+
+#include <cassert>
+
+int copy_count = 0;
+int dtor_count = 0;
+
+struct X
+{
+ X() = default;
+ X(const X&) { ++copy_count; }
+ ~X() { ++dtor_count; }
+};
+
+int main()
+{
+ {
+ X x;
+ auto z = [y = x](){};
+ X x2;
+ auto z2 = [x2](){};
+ assert(copy_count == 2);
+ }
+ assert(dtor_count == 4);
+}
[-- Attachment #3: pr61133.changelog --]
[-- Type: application/octet-stream, Size: 346 bytes --]
/cp
2014-05-10 Ville Voutilainen <ville.voutilainen@gmail.com>
PR c++/61133
* lambda.c (build_capture_proxy, add_capture): Treat normal captures and init-captures identically.
/testsuite
2014-05-10 Ville Voutilainen <ville.voutilainen@gmail.com>
PR c++/61133
* g++.dg/cpp1y/lambda-init6.C: Adjust.
* g++.dg/cpp1y/lambda-init8.C: New.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [C++ patch] Fix c++/PR61133, implement the resolution of DR1760
2014-05-09 23:02 [C++ patch] Fix c++/PR61133, implement the resolution of DR1760 Ville Voutilainen
@ 2014-05-21 17:43 ` Jason Merrill
0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2014-05-21 17:43 UTC (permalink / raw)
To: Ville Voutilainen, gcc-patches
Applied, thanks.
Jason
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-05-21 17:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-09 23:02 [C++ patch] Fix c++/PR61133, implement the resolution of DR1760 Ville Voutilainen
2014-05-21 17:43 ` Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).