diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2012-02-07 00:15:00 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2012-02-07 00:15:00 +0000 |
commit | 0a29422eb722c0ffbb98b98d8636042b19069f1a (patch) | |
tree | a05c8d41e8c6cdab329772107b7e7c23da654e10 /test | |
parent | f9ea953f22d8e50cae7fd541406d6f563ef86cda (diff) |
Misc improvements to the diagnostic when a variable is odr-used in a context that is not allowed to capture variables.
Fixes PR11883.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149937 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/CXX/class/class.local/p1-0x.cpp | 18 | ||||
-rw-r--r-- | test/CXX/class/class.local/p1.cpp | 2 | ||||
-rw-r--r-- | test/CXX/class/class.local/p3.cpp | 2 | ||||
-rw-r--r-- | test/SemaCXX/c99-variable-length-array.cpp | 3 |
4 files changed, 22 insertions, 3 deletions
diff --git a/test/CXX/class/class.local/p1-0x.cpp b/test/CXX/class/class.local/p1-0x.cpp new file mode 100644 index 0000000000..8916295825 --- /dev/null +++ b/test/CXX/class/class.local/p1-0x.cpp @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s + +void f() { + int x = 3; // expected-note{{'x' declared here}} + const int c = 2; + struct C { + int& x2 = x; // expected-error{{reference to local variable 'x' declared in enclosing function 'f'}} + int cc = c; + }; + []() mutable { // expected-error {{not supported yet}} + int x = 3; // expected-note{{'x' declared here}} + struct C { + int& x2 = x; // expected-error{{reference to local variable 'x' declared in enclosing lambda expression}} + }; + } + C(); +} + diff --git a/test/CXX/class/class.local/p1.cpp b/test/CXX/class/class.local/p1.cpp index 05ae5c71d1..62ade5cb88 100644 --- a/test/CXX/class/class.local/p1.cpp +++ b/test/CXX/class/class.local/p1.cpp @@ -8,7 +8,7 @@ void f() extern int g(); struct local { - int g() { return x; } // expected-error{{reference to local variable 'x' declared in enclosed function 'f'}} + int g() { return x; } // expected-error{{reference to local variable 'x' declared in enclosing function 'f'}} int h() { return s; } int k() { return :: x; } int l() { return g(); } diff --git a/test/CXX/class/class.local/p3.cpp b/test/CXX/class/class.local/p3.cpp index c24d5d8a09..3753790384 100644 --- a/test/CXX/class/class.local/p3.cpp +++ b/test/CXX/class/class.local/p3.cpp @@ -24,7 +24,7 @@ void f2() { void f3(int a) { // expected-note{{'a' declared here}} struct X { struct Y { - int f() { return a; } // expected-error{{reference to local variable 'a' declared in enclosed function 'f3'}} + int f() { return a; } // expected-error{{reference to local variable 'a' declared in enclosing function 'f3'}} }; }; } diff --git a/test/SemaCXX/c99-variable-length-array.cpp b/test/SemaCXX/c99-variable-length-array.cpp index 2f9bb957ec..7773c0849b 100644 --- a/test/SemaCXX/c99-variable-length-array.cpp +++ b/test/SemaCXX/c99-variable-length-array.cpp @@ -73,10 +73,11 @@ void test_accept_array(int N) { } // Variably-modified types cannot be used in local classes. -void local_classes(int N) { +void local_classes(int N) { // expected-note {{declared here}} struct X { int size; int array[N]; // expected-error{{fields must have a constant size: 'variable length array in structure' extension will never be supported}} \ + // expected-error{{reference to local variable 'N' declared in enclosing function 'local_classes'}} \ // expected-warning{{variable length arrays are a C99 feature}} }; } |