aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
authorIain Sandoe <iain@codesourcery.com>2014-12-31 13:58:16 +0000
committerIain Sandoe <iains@gcc.gnu.org>2014-12-31 13:58:16 +0000
commite8ef82d74f40e216b3a1c9707a79a3bd0b6c953d (patch)
tree89e697fd28a192c9f4e58f50181106401914964d /gcc/testsuite
parent0d391d25ae4899249202ec9d68a8c576165d5ba2 (diff)
downloadgcc-e8ef82d74f40e216b3a1c9707a79a3bd0b6c953d.zip
gcc-e8ef82d74f40e216b3a1c9707a79a3bd0b6c953d.tar.gz
gcc-e8ef82d74f40e216b3a1c9707a79a3bd0b6c953d.tar.bz2
Allow Objective-c++ to recognise lambdas.
gcc/cp: * parser.c (cp_parser_primary_expression): If parsing an objective-c++ message expression fails, see if a lambda is present. (cp_parser_objc_message_receiver): Don't assume that, if a message receiver expression fails, it is a hard error. gcc/testsuite: * obj-c++.dg/lambda-0.mm New. * obj-c++.dg/lambda-1.mm New. * obj-c++.dg/syntax-error-6.mm Adjust for revised error messages. From-SVN: r219125
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/obj-c++.dg/lambda-0.mm22
-rw-r--r--gcc/testsuite/obj-c++.dg/lambda-1.mm13
-rw-r--r--gcc/testsuite/obj-c++.dg/syntax-error-6.mm5
4 files changed, 45 insertions, 1 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 6e7a99e..03531d38 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,11 @@
2014-12-31 Iain Sandoe <iain@codesourcery.com>
+ * obj-c++.dg/lambda-0.mm New.
+ * obj-c++.dg/lambda-1.mm New.
+ * obj-c++.dg/syntax-error-6.mm Adjust for revised error messages.
+
+2014-12-31 Iain Sandoe <iain@codesourcery.com>
+
* obj-c++.dg/standard-headers.mm New.
2014-12-30 Jan Hubicka <hubicka@ucw.cz>
diff --git a/gcc/testsuite/obj-c++.dg/lambda-0.mm b/gcc/testsuite/obj-c++.dg/lambda-0.mm
new file mode 100644
index 0000000..41482fd
--- /dev/null
+++ b/gcc/testsuite/obj-c++.dg/lambda-0.mm
@@ -0,0 +1,22 @@
+// Contributed by Iain Sandoe <iain@codesourcery.com>, December 2014. */
+// { dg-do compile }
+// { dg-options "-std=c++11" }
+
+
+template<class Function>
+Function thing(Function fn, int a)
+{
+ fn(a);
+ return fn;
+}
+
+int
+test (int *arr, unsigned n)
+{
+ int total = 0;
+ for (unsigned i=0; i<n; i++) {
+ int a = arr[i];
+ thing ([&total] (int a) { total += a; }, a);
+ }
+ return total;
+}
diff --git a/gcc/testsuite/obj-c++.dg/lambda-1.mm b/gcc/testsuite/obj-c++.dg/lambda-1.mm
new file mode 100644
index 0000000..050d68d
--- /dev/null
+++ b/gcc/testsuite/obj-c++.dg/lambda-1.mm
@@ -0,0 +1,13 @@
+// Contributed by Iain Sandoe <iain@codesourcery.com>, December 2014. */
+// { dg-do compile }
+// { dg-options "-std=c++11" }
+
+extern "C" {
+ int printf (const char *,...);
+}
+
+int main ()
+{
+ auto f = [] (const char *msg) -> int { printf("%s", msg); return 0; };
+ return f("Some test\n");
+}
diff --git a/gcc/testsuite/obj-c++.dg/syntax-error-6.mm b/gcc/testsuite/obj-c++.dg/syntax-error-6.mm
index 21423ec..36a444f 100644
--- a/gcc/testsuite/obj-c++.dg/syntax-error-6.mm
+++ b/gcc/testsuite/obj-c++.dg/syntax-error-6.mm
@@ -8,5 +8,8 @@ void FOO()
{
NSButton * mCopyAcrobatCB;
- [ [ mCopyAcrobatCB state ] == 0 ] != 1; /* { dg-error "objective\\-c\\+\\+" } */
+ [ [ mCopyAcrobatCB state ] == 0 ] != 1; /* { dg-error "expected identifier before ... token" } */
+/* { dg-error "expected \\\'\\\{\\\' before \\\'!=\\\' token" "" { target *-*-* } 11 } */
+/* { dg-error "lambda expressions only available with" "" { target *-*-* } 11 } */
+/* { dg-error "no match for \\\'operator!=\\\' in" "" { target *-*-* } 11 } */
}