Author: vsapsai Date: Tue Aug 22 10:55:19 2017 New Revision: 311480 URL: http://llvm.org/viewvc/llvm-project?rev=311480&view=rev Log: [Parser] Correct initalizer typos before lambda capture type is deduced.
This is the same assertion as in https://reviews.llvm.org/D25206 that is triggered when RecordLayoutBuilder tries to compute the size of a field (for capture "typo_boo" in the test case) whose type hasn't been deduced. The fix is to add CorrectDelayedTyposInExpr call to the cases when we aren't disambiguating between an Obj-C message send and a lambda expression. rdar://problem/31760839 Reviewers: rsmith, ahatanak Reviewed By: arphaman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D36853 Modified: cfe/trunk/lib/Parse/ParseExprCXX.cpp cfe/trunk/test/SemaCXX/cxx1y-init-captures.cpp Modified: cfe/trunk/lib/Parse/ParseExprCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=311480&r1=311479&r2=311480&view=diff ============================================================================== --- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original) +++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Tue Aug 22 10:55:19 2017 @@ -966,6 +966,8 @@ Optional<unsigned> Parser::ParseLambdaIn // that would be an error. ParsedType InitCaptureType; + if (!Init.isInvalid()) + Init = Actions.CorrectDelayedTyposInExpr(Init.get()); if (Init.isUsable()) { // Get the pointer and store it in an lvalue, so we can use it as an // out argument. Modified: cfe/trunk/test/SemaCXX/cxx1y-init-captures.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1y-init-captures.cpp?rev=311480&r1=311479&r2=311480&view=diff ============================================================================== --- cfe/trunk/test/SemaCXX/cxx1y-init-captures.cpp (original) +++ cfe/trunk/test/SemaCXX/cxx1y-init-captures.cpp Tue Aug 22 10:55:19 2017 @@ -206,3 +206,11 @@ void test(double weight) { find(weight); // expected-note {{in instantiation of function template specialization}} } } + +namespace init_capture_undeclared_identifier { + auto a = [x = y]{}; // expected-error{{use of undeclared identifier 'y'}} + + int typo_foo; // expected-note 2 {{'typo_foo' declared here}} + auto b = [x = typo_boo]{}; // expected-error{{use of undeclared identifier 'typo_boo'; did you mean 'typo_foo'}} + auto c = [x(typo_boo)]{}; // expected-error{{use of undeclared identifier 'typo_boo'; did you mean 'typo_foo'}} +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits