aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/CXX/class/class.local/p1-0x.cpp18
-rw-r--r--test/CXX/class/class.local/p1.cpp2
-rw-r--r--test/CXX/class/class.local/p3.cpp2
-rw-r--r--test/SemaCXX/c99-variable-length-array.cpp3
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}}
};
}