-
- Downloads
Merging r286584:
------------------------------------------------------------------------ r286584 | abataev | 2016-11-11 12:36:20 +0000 (Fri, 11 Nov 2016) | 31 lines Fix for PR28523: unexpected compilation error. Clang emits error message for the following code: ``` template <class F> void parallel_loop(F &&f) { f(0); } int main() { int x; parallel_loop([&](auto y) { { x = y; }; }); } ``` $ clang++ --std=gnu++14 clang_test.cc -o clang_test clang_test.cc:9:7: error: reference to local variable 'x' declared in enclosing function 'main' x = y; ^ clang_test.cc:2:48: note: in instantiation of function template specialization 'main()::(anonymous class)::operator()<int>' requested here template <class F> void parallel_loop(F &&f) { f(0); } ^ clang_test.cc:6:3: note: in instantiation of function template specialization 'parallel_loop<(lambda at clang_test.cc:6:17)>' requested here parallel_loop([&](auto y) { ^ clang_test.cc:5:7: note: 'x' declared here int x; ^ 1 error generated. Patch fixes this issue. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_39@286966 91177308-0d34-0410-b5e6-96231b3b80d8
Showing
- include/clang/Sema/Sema.h 4 additions, 2 deletionsinclude/clang/Sema/Sema.h
- lib/Sema/Sema.cpp 10 additions, 2 deletionslib/Sema/Sema.cpp
- lib/Sema/SemaExpr.cpp 2 additions, 1 deletionlib/Sema/SemaExpr.cpp
- lib/Sema/SemaExprCXX.cpp 15 additions, 5 deletionslib/Sema/SemaExprCXX.cpp
- lib/Sema/SemaLambda.cpp 7 additions, 4 deletionslib/Sema/SemaLambda.cpp
- test/CodeGenCXX/PR28523.cpp 19 additions, 0 deletionstest/CodeGenCXX/PR28523.cpp
Loading
Please register or sign in to comment