aboutsummaryrefslogtreecommitdiff
path: root/test/SemaCXX/warn-unused-filescoped.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2013-12-22 00:07:40 +0000
committerDimitry Andric <dim@FreeBSD.org>2013-12-22 00:07:40 +0000
commitbfef399519ca9b8a4b4c6b563253bad7e0eeffe0 (patch)
treedf8df0b0067b381eab470a3b8f28d14a552a6340 /test/SemaCXX/warn-unused-filescoped.cpp
parent6a0372513edbc473b538d2f724efac50405d6fef (diff)
downloadsrc-bfef399519ca9b8a4b4c6b563253bad7e0eeffe0.tar.gz
src-bfef399519ca9b8a4b4c6b563253bad7e0eeffe0.zip
Vendor import of clang release_34 branch r197841 (effectively, 3.4 RC3):vendor/clang/clang-release_34-r197841
Notes
Notes: svn path=/vendor/clang/dist/; revision=259701 svn path=/vendor/clang/clang-release_34-r197841/; revision=259703; tag=vendor/clang/clang-release_34-r197841
Diffstat (limited to 'test/SemaCXX/warn-unused-filescoped.cpp')
-rw-r--r--test/SemaCXX/warn-unused-filescoped.cpp81
1 files changed, 57 insertions, 24 deletions
diff --git a/test/SemaCXX/warn-unused-filescoped.cpp b/test/SemaCXX/warn-unused-filescoped.cpp
index 9fb601130d3b..b0af5b332270 100644
--- a/test/SemaCXX/warn-unused-filescoped.cpp
+++ b/test/SemaCXX/warn-unused-filescoped.cpp
@@ -1,6 +1,41 @@
// RUN: %clang_cc1 -fsyntax-only -verify -Wunused -Wunused-member-function -Wno-c++11-extensions -std=c++98 %s
// RUN: %clang_cc1 -fsyntax-only -verify -Wunused -Wunused-member-function -std=c++11 %s
+#ifdef HEADER
+
+static void headerstatic() {} // expected-warning{{unused}}
+static inline void headerstaticinline() {}
+
+namespace {
+ void headeranon() {} // expected-warning{{unused}}
+ inline void headerinlineanon() {}
+}
+
+namespace test7
+{
+ template<typename T>
+ static inline void foo(T) { }
+
+ // This should not emit an unused-function warning since it inherits
+ // the static storage type from the base template.
+ template<>
+ inline void foo(int) { }
+
+ // Partial specialization
+ template<typename T, typename U>
+ static inline void bar(T, U) { }
+
+ template<typename U>
+ inline void bar(int, U) { }
+
+ template<>
+ inline void bar(int, int) { }
+};
+
+#else
+#define HEADER
+#include "warn-unused-filescoped.cpp"
+
static void f1(); // expected-warning{{unused}}
namespace {
@@ -37,8 +72,10 @@ namespace {
void S::m3() { } // expected-warning{{unused}}
-static inline void f4() { }
-const unsigned int cx = 0;
+static inline void f4() { } // expected-warning{{unused}}
+const unsigned int cx = 0; // expected-warning{{unused}}
+const unsigned int cy = 0;
+int f5() { return cy; }
static int x1; // expected-warning{{unused}}
@@ -98,7 +135,7 @@ namespace test5 {
// FIXME: We should produce warnings for both of these.
static const int m = n;
int x = sizeof(m);
- static const double d = 0.0;
+ static const double d = 0.0; // expected-warning{{not needed and will not be emitted}}
int y = sizeof(d);
}
@@ -133,27 +170,6 @@ namespace test6 {
};
}
-namespace test7
-{
- template<typename T>
- static inline void foo(T) { }
-
- // This should not emit an unused-function warning since it inherits
- // the static storage type from the base template.
- template<>
- inline void foo(int) { }
-
- // Partial specialization
- template<typename T, typename U>
- static inline void bar(T, U) { }
-
- template<typename U>
- inline void bar(int, U) { }
-
- template<>
- inline void bar(int, int) { }
-};
-
namespace pr14776 {
namespace {
struct X {};
@@ -161,3 +177,20 @@ namespace pr14776 {
X a = X(); // expected-warning {{unused variable 'a'}}
auto b = X(); // expected-warning {{unused variable 'b'}}
}
+
+namespace UndefinedInternalStaticMember {
+ namespace {
+ struct X {
+ static const unsigned x = 3;
+ int y[x];
+ };
+ }
+}
+
+namespace test8 {
+static void func();
+void bar() { void func() __attribute__((used)); }
+static void func() {}
+}
+
+#endif