diff options
Diffstat (limited to 'test/SemaCXX/warn-unused-variables.cpp')
-rw-r--r-- | test/SemaCXX/warn-unused-variables.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/SemaCXX/warn-unused-variables.cpp b/test/SemaCXX/warn-unused-variables.cpp index d7be785b35a6..a7ac9afc36ad 100644 --- a/test/SemaCXX/warn-unused-variables.cpp +++ b/test/SemaCXX/warn-unused-variables.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -fsyntax-only -Wunused-variable -Wunused-label -Wno-c++1y-extensions -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wunused-variable -Wunused-label -Wno-c++1y-extensions -verify -std=c++11 %s template<typename T> void f() { T t; t = 17; @@ -194,3 +195,45 @@ void test() { } } + +#if __cplusplus >= 201103L +namespace with_constexpr { +template <typename T> +struct Literal { + T i; + Literal() = default; + constexpr Literal(T i) : i(i) {} +}; + +struct NoLiteral { + int i; + NoLiteral() = default; + constexpr NoLiteral(int i) : i(i) {} + ~NoLiteral() {} +}; + +static Literal<int> gl1; // expected-warning {{unused variable 'gl1'}} +static Literal<int> gl2(1); // expected-warning {{unused variable 'gl2'}} +static const Literal<int> gl3(0); // expected-warning {{unused variable 'gl3'}} + +template <typename T> +void test(int i) { + Literal<int> l1; // expected-warning {{unused variable 'l1'}} + Literal<int> l2(42); // expected-warning {{unused variable 'l2'}} + Literal<int> l3(i); // no-warning + Literal<T> l4(0); // no-warning + NoLiteral nl1; // no-warning + NoLiteral nl2(42); // no-warning +} +} + +namespace crash { +struct a { + a(const char *); +}; +template <typename b> +void c() { + a d(b::e ? "" : ""); +} +} +#endif |