aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@gcc.gnu.org>2016-03-18 01:23:26 +0000
committerPatrick Palka <ppalka@gcc.gnu.org>2016-03-18 01:23:26 +0000
commit753a8910a4c9021ff81e9892ac58c50c0fdb6d69 (patch)
tree6c27e45dd0c7221674892f4c5dac59d16ea73e65 /gcc
parent4a8e35b32ce7b8af8719e15ef26fbe2575d16610 (diff)
downloadgcc-753a8910a4c9021ff81e9892ac58c50c0fdb6d69.zip
gcc-753a8910a4c9021ff81e9892ac58c50c0fdb6d69.tar.gz
gcc-753a8910a4c9021ff81e9892ac58c50c0fdb6d69.tar.bz2
Fix PR c++/70218 (illegal access to private field succeeds)
gcc/cp/ChangeLog: PR c++/70218 * parser.c (cp_parser_lambda_expression): Move call to pop_deferring_access_checks ahead of the call to cp_parser_end_tentative_firewall. gcc/testsuite/ChangeLog: PR c++/70218 * g++.dg/cpp0x/lambda/lambda-70218.C: New test. From-SVN: r234316
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/parser.c4
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/lambda/lambda-70218.C17
4 files changed, 31 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 15ca9a4..764122a 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+2016-03-18 Patrick Palka <ppalka@gcc.gnu.org>
+
+ PR c++/70218
+ * parser.c (cp_parser_lambda_expression): Move call to
+ pop_deferring_access_checks ahead of the call to
+ cp_parser_end_tentative_firewall.
+
2016-03-17 Jakub Jelinek <jakub@redhat.com>
PR c++/70144
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 8ba4ffe..7e13c6e7 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -9781,8 +9781,6 @@ cp_parser_lambda_expression (cp_parser* parser)
= auto_is_implicit_function_template_parm_p;
}
- pop_deferring_access_checks ();
-
/* This field is only used during parsing of the lambda. */
LAMBDA_EXPR_THIS_CAPTURE (lambda_expr) = NULL_TREE;
@@ -9798,6 +9796,8 @@ cp_parser_lambda_expression (cp_parser* parser)
cp_parser_end_tentative_firewall (parser, start, lambda_expr);
+ pop_deferring_access_checks ();
+
return lambda_expr;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 4fa5519..5f792ee 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2016-03-18 Patrick Palka <ppalka@gcc.gnu.org>
+
+ PR c++/70218
+ * g++.dg/cpp0x/lambda/lambda-70218.C: New test.
+
2016-03-17 Marek Polacek <polacek@redhat.com>
PR c/69407
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-70218.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-70218.C
new file mode 100644
index 0000000..ae8cc2f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-70218.C
@@ -0,0 +1,17 @@
+// PR c++/70218
+// { dg-do compile { target c++11 } }
+
+struct X {
+private:
+ int i;
+};
+
+struct Y {
+ Y (int) { }
+};
+
+void
+foo ()
+{
+ Y ([] { X x; x.i = 3; return 0; } ()); // { dg-error "private" }
+}