[Parser] Lambda capture lists can start with '*'
authorErik Pilkington <erik.pilkington@gmail.com>
Tue, 30 Jul 2019 19:21:20 +0000 (19:21 +0000)
committerErik Pilkington <erik.pilkington@gmail.com>
Tue, 30 Jul 2019 19:21:20 +0000 (19:21 +0000)
Fixes llvm.org/PR42778

llvm-svn: 367346

clang/lib/Parse/ParseInit.cpp
clang/test/Parser/cxx0x-lambda-expressions.cpp

index 7a45548..769140f 100644 (file)
@@ -45,6 +45,7 @@ bool Parser::MayBeDesignationStart() {
 
     case tok::amp:
     case tok::kw_this:
+    case tok::star:
     case tok::identifier:
       // We have to do additional analysis, because these could be the
       // start of a constant expression or a lambda capture list.
index b297d73..2acd814 100644 (file)
@@ -126,6 +126,19 @@ void PR22122() {
 
 template void PR22122<int>();
 
+namespace PR42778 {
+struct A {
+  template <class F> A(F&&) {}
+};
+
+struct S {
+  void mf() { A{[*this]{}}; }
+#if __cplusplus < 201703L
+  // expected-warning@-2 {{C++17 extension}}
+#endif
+};
+}
+
 struct S {
   template <typename T>
   void m (T x =[0); // expected-error{{expected variable name or 'this' in lambda capture list}}