aboutsummaryrefslogtreecommitdiff
path: root/test/SemaCXX
diff options
context:
space:
mode:
Diffstat (limited to 'test/SemaCXX')
-rw-r--r--test/SemaCXX/coroutines.cpp3
-rw-r--r--test/SemaCXX/cxx0x-class.cpp8
-rw-r--r--test/SemaCXX/cxx1y-variable-templates_top_level.cpp5
-rw-r--r--test/SemaCXX/diagnose_if-ext.cpp8
-rw-r--r--test/SemaCXX/uninitialized.cpp12
-rw-r--r--test/SemaCXX/warn-shadow-in-lambdas.cpp8
-rw-r--r--test/SemaCXX/warn-shadow.cpp10
7 files changed, 51 insertions, 3 deletions
diff --git a/test/SemaCXX/coroutines.cpp b/test/SemaCXX/coroutines.cpp
index a22383cd566b..158b1a7c7dd4 100644
--- a/test/SemaCXX/coroutines.cpp
+++ b/test/SemaCXX/coroutines.cpp
@@ -154,12 +154,11 @@ void mixed_await() {
}
void only_coreturn(void_tag) {
- co_return; // expected-warning {{'co_return' used in a function that uses neither 'co_await' nor 'co_yield'}}
+ co_return; // OK
}
void mixed_coreturn(void_tag, bool b) {
if (b)
- // expected-warning@+1 {{'co_return' used in a function that uses neither}}
co_return; // expected-note {{use of 'co_return'}}
else
return; // expected-error {{not allowed in coroutine}}
diff --git a/test/SemaCXX/cxx0x-class.cpp b/test/SemaCXX/cxx0x-class.cpp
index 2b1338f97fd7..8afb0fd6f3c0 100644
--- a/test/SemaCXX/cxx0x-class.cpp
+++ b/test/SemaCXX/cxx0x-class.cpp
@@ -37,3 +37,11 @@ namespace Foo {
int y = x;
};
}
+
+// Instantiating another default member initializer while parsing one should
+// not cause us to mess up the 'this' override.
+template<typename> struct DefaultMemberTemplate { int n = 0; };
+class DefaultMemberInitSelf {
+ DefaultMemberTemplate<int> t = {};
+ int *p = &t.n;
+};
diff --git a/test/SemaCXX/cxx1y-variable-templates_top_level.cpp b/test/SemaCXX/cxx1y-variable-templates_top_level.cpp
index ec3e2b6f63d1..367f67bf5fa8 100644
--- a/test/SemaCXX/cxx1y-variable-templates_top_level.cpp
+++ b/test/SemaCXX/cxx1y-variable-templates_top_level.cpp
@@ -464,3 +464,8 @@ template <typename... Args> Variadic_t<Args...> Variadic;
auto variadic1 = Variadic<>;
auto variadic2 = Variadic<int, int>;
#endif
+
+namespace VexingParse {
+ template <typename> int var; // expected-note {{declared here}}
+ int x(var); // expected-error {{cannot refer to variable template 'var' without a template argument list}}
+}
diff --git a/test/SemaCXX/diagnose_if-ext.cpp b/test/SemaCXX/diagnose_if-ext.cpp
new file mode 100644
index 000000000000..d5625b501322
--- /dev/null
+++ b/test/SemaCXX/diagnose_if-ext.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -Wpedantic -fsyntax-only %s -verify
+
+void foo() __attribute__((diagnose_if(1, "", "error"))); // expected-warning{{'diagnose_if' is a clang extension}}
+void foo(int a) __attribute__((diagnose_if(a, "", "error"))); // expected-warning{{'diagnose_if' is a clang extension}}
+// FIXME: When diagnose_if gets a CXX11 spelling, this should be enabled.
+#if 0
+[[clang::diagnose_if(a, "", "error")]] void foo(double a);
+#endif
diff --git a/test/SemaCXX/uninitialized.cpp b/test/SemaCXX/uninitialized.cpp
index 5769a0c028c8..7a23f3cef2c4 100644
--- a/test/SemaCXX/uninitialized.cpp
+++ b/test/SemaCXX/uninitialized.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wall -Wuninitialized -Wno-unused-value -std=c++11 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wall -Wuninitialized -Wno-unused-value -std=c++1z -verify %s
// definitions for std::move
namespace std {
@@ -1437,3 +1437,13 @@ void array_capture(bool b) {
[fname]{};
}
}
+
+void if_switch_init_stmt(int k) {
+ if (int n = 0; (n == k || k > 5)) {}
+
+ if (int n; (n == k || k > 5)) {} // expected-warning {{uninitialized}} expected-note {{initialize}}
+
+ switch (int n = 0; (n == k || k > 5)) {} // expected-warning {{boolean}}
+
+ switch (int n; (n == k || k > 5)) {} // expected-warning {{uninitialized}} expected-note {{initialize}} expected-warning {{boolean}}
+}
diff --git a/test/SemaCXX/warn-shadow-in-lambdas.cpp b/test/SemaCXX/warn-shadow-in-lambdas.cpp
index 575664482dbe..b0dcd122a540 100644
--- a/test/SemaCXX/warn-shadow-in-lambdas.cpp
+++ b/test/SemaCXX/warn-shadow-in-lambdas.cpp
@@ -137,3 +137,11 @@ void foo(int param) { // expected-note 1+ {{previous declaration is here}}
auto g3 = [param] // expected-note {{variable 'param' is explicitly captured here}}
(auto param) { ; }; // expected-warning {{declaration shadows a local variable}}
}
+
+void avoidWarningWhenRedefining() {
+ int a = 1;
+ auto l = [b = a] { // expected-note {{previous definition is here}}
+ // Don't warn on redefinitions.
+ int b = 0; // expected-error {{redefinition of 'b'}}
+ };
+}
diff --git a/test/SemaCXX/warn-shadow.cpp b/test/SemaCXX/warn-shadow.cpp
index 9d68fe7c47a6..1316b6dd8871 100644
--- a/test/SemaCXX/warn-shadow.cpp
+++ b/test/SemaCXX/warn-shadow.cpp
@@ -97,3 +97,13 @@ void rdar8883302() {
void test8() {
int bob; // expected-warning {{declaration shadows a variable in the global namespace}}
}
+
+namespace rdar29067894 {
+
+void avoidWarningWhenRedefining(int b) { // expected-note {{previous definition is here}}
+ int a = 0; // expected-note {{previous definition is here}}
+ int a = 1; // expected-error {{redefinition of 'a'}}
+ int b = 2; // expected-error {{redefinition of 'b'}}
+}
+
+}