summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/SemaCXX')
-rw-r--r--clang/test/SemaCXX/warn-everthing.cpp2
-rw-r--r--clang/test/SemaCXX/warn-unused-variables.cpp51
2 files changed, 52 insertions, 1 deletions
diff --git a/clang/test/SemaCXX/warn-everthing.cpp b/clang/test/SemaCXX/warn-everthing.cpp
index ad3dd8a24d8..ff66c78cdf9 100644
--- a/clang/test/SemaCXX/warn-everthing.cpp
+++ b/clang/test/SemaCXX/warn-everthing.cpp
@@ -9,5 +9,5 @@ public:
};
void testPR12271() { // expected-warning {{no previous prototype for function 'testPR12271'}}
- PR12271 a[1][1]; // expected-warning {{unused variable 'a'}}
+ PR12271 a[1][1];
}
diff --git a/clang/test/SemaCXX/warn-unused-variables.cpp b/clang/test/SemaCXX/warn-unused-variables.cpp
index 8dcbe7271d6..e40cf1a2c9c 100644
--- a/clang/test/SemaCXX/warn-unused-variables.cpp
+++ b/clang/test/SemaCXX/warn-unused-variables.cpp
@@ -150,3 +150,54 @@ namespace ctor_with_cleanups {
}
#include "Inputs/warn-unused-variables.h"
+
+namespace arrayRecords {
+
+int total = 0;
+
+class Adder {
+public:
+ Adder(int x); // out of line below
+ ~Adder() {}
+};
+
+Adder::Adder(int x) {
+ total += x;
+}
+
+struct Foo {
+ int x;
+ Foo(int x) : x(x) {}
+};
+
+struct S1 {
+ S1();
+};
+
+void foo(int size) {
+ S1 y; // no warning
+ S1 yarray[2]; // no warning
+ S1 dynArray[size]; // no warning
+ S1 nestedArray[1][2][3]; // no warning
+
+ Adder scalerInFuncScope = 134; // no warning
+ Adder arrayInFuncScope[] = { 135, 136 }; // no warning
+ Adder nestedArrayInFuncScope[2][2] = { {1,2}, {3,4} }; // no warning
+
+ Foo fooScalar = 1; // expected-warning {{unused variable 'fooScalar'}}
+ Foo fooArray[] = {1,2}; // expected-warning {{unused variable 'fooArray'}}
+ Foo fooNested[2][2] = { {1,2}, {3,4} }; // expected-warning {{unused variable 'fooNested'}}
+}
+
+template<int N>
+void bar() {
+ Adder scaler = 123; // no warning
+ Adder array[N] = {1,2}; // no warning
+}
+
+void test() {
+ foo(10);
+ bar<2>();
+}
+
+}
OpenPOWER on IntegriCloud