[PATCH] D25206: [Parser] Correct typo after lambda capture initializer is parsed
Akira Hatanaka via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 3 12:07:10 PDT 2016
ahatanak created this revision.
ahatanak added a reviewer: rsmith.
ahatanak added a subscriber: cfe-commits.
This fixes PR30566.
The assertion is triggered when RecordLayoutBuilder tries to compute the size of a field (for capture "name" in the test case) whose type hasn't been deduced. This fixes the bug by correcting the typo of the capture initializer after the initializer is parsed and before setting the expression for the annotation token.
rdar://problem/23380132
https://reviews.llvm.org/D25206
Files:
lib/Parse/ParseExprCXX.cpp
test/SemaCXX/lambda-expressions.cpp
Index: test/SemaCXX/lambda-expressions.cpp
===================================================================
--- test/SemaCXX/lambda-expressions.cpp
+++ test/SemaCXX/lambda-expressions.cpp
@@ -525,3 +525,17 @@
decltype(a)::D b;
}
}
+
+namespace PR30566 {
+int name1; // expected-note {{'name1' declared here}}
+
+struct S1 {
+ template<class T>
+ S1(T t) { s = sizeof(t); }
+ int s;
+};
+
+void foo1() {
+ auto s1 = S1{[name=name]() {}}; // expected-error {{use of undeclared identifier 'name'; did you mean 'name1'?}}
+}
+}
Index: lib/Parse/ParseExprCXX.cpp
===================================================================
--- lib/Parse/ParseExprCXX.cpp
+++ lib/Parse/ParseExprCXX.cpp
@@ -948,6 +948,7 @@
SourceLocation StartLoc = Tok.getLocation();
InMessageExpressionRAIIObject MaybeInMessageExpression(*this, true);
Init = ParseInitializer();
+ Init = Actions.CorrectDelayedTyposInExpr(Init.get());
if (Tok.getLocation() != StartLoc) {
// Back out the lexing of the token after the initializer.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25206.73317.patch
Type: text/x-patch
Size: 1081 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161003/43874320/attachment.bin>
More information about the cfe-commits
mailing list