aboutsummaryrefslogtreecommitdiff
path: root/test/SemaCXX
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-01-06 20:13:35 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-01-06 20:13:35 +0000
commit6694ed095d6b27a2c92ec4fd63664fcd88a05749 (patch)
tree0633c29bd8350e306f3a24a30f3f6045efd35420 /test/SemaCXX
parentd5dc75c5cf109efe52b1da32ec44a667389a0f0a (diff)
downloadsrc-6694ed095d6b27a2c92ec4fd63664fcd88a05749.tar.gz
src-6694ed095d6b27a2c92ec4fd63664fcd88a05749.zip
Vendor import of clang trunk r291274:vendor/clang/clang-trunk-r291274
Notes
Notes: svn path=/vendor/clang/dist/; revision=311534 svn path=/vendor/clang/clang-trunk-r291274/; revision=311535; tag=vendor/clang/clang-trunk-r291274
Diffstat (limited to 'test/SemaCXX')
-rw-r--r--test/SemaCXX/constant-expression-cxx11.cpp4
-rw-r--r--test/SemaCXX/conversion-function.cpp2
-rw-r--r--test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp26
-rw-r--r--test/SemaCXX/cxx1z-decomposition.cpp5
-rw-r--r--test/SemaCXX/default-arg-closures.cpp9
-rw-r--r--test/SemaCXX/dllexport.cpp21
-rw-r--r--test/SemaCXX/type-definition-in-specifier.cpp6
7 files changed, 58 insertions, 15 deletions
diff --git a/test/SemaCXX/constant-expression-cxx11.cpp b/test/SemaCXX/constant-expression-cxx11.cpp
index 581a524339e7..884f2f30c42f 100644
--- a/test/SemaCXX/constant-expression-cxx11.cpp
+++ b/test/SemaCXX/constant-expression-cxx11.cpp
@@ -1725,7 +1725,7 @@ namespace AfterError {
constexpr int error() { // expected-error {{no return statement}}
return foobar; // expected-error {{undeclared identifier}}
}
- constexpr int k = error(); // expected-error {{must be initialized by a constant expression}}
+ constexpr int k = error();
}
namespace std {
@@ -2030,7 +2030,7 @@ namespace PR21786 {
namespace PR21859 {
constexpr int Fun() { return; } // expected-error {{non-void constexpr function 'Fun' should return a value}}
- constexpr int Var = Fun(); // expected-error {{constexpr variable 'Var' must be initialized by a constant expression}}
+ constexpr int Var = Fun();
}
struct InvalidRedef {
diff --git a/test/SemaCXX/conversion-function.cpp b/test/SemaCXX/conversion-function.cpp
index c725a0d5b7c1..531de818b680 100644
--- a/test/SemaCXX/conversion-function.cpp
+++ b/test/SemaCXX/conversion-function.cpp
@@ -440,7 +440,7 @@ namespace PR18234 {
#endif
} a;
A::S s = a; // expected-error {{no viable conversion from 'struct A' to 'A::S'}}
- A::E e = a; // expected-note {{here}}
+ A::E e = a;
bool k1 = e == A::e; // expected-error {{no member named 'e'}}
bool k2 = e.n == 0;
}
diff --git a/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp b/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
index 75c6734bce30..9b8fadd2f522 100644
--- a/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
+++ b/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
@@ -105,6 +105,7 @@ T deduce_ref(const std::initializer_list<T>&); // expected-note {{conflicting ty
template<typename T, typename U> struct pair { pair(...); };
template<typename T> void deduce_pairs(std::initializer_list<pair<T, typename T::type>>);
+// expected-note@-1 {{deduced type 'pair<[...], typename WithIntType::type>' of element of 1st parameter does not match adjusted type 'pair<[...], float>' of element of argument [with T = WithIntType]}}
struct WithIntType { typedef int type; };
template<typename ...T> void deduce_after_init_list_in_pack(void (*)(T...), T...); // expected-note {{<int, int> vs. <(no value), double>}}
@@ -123,7 +124,7 @@ void argument_deduction() {
pair<WithIntType, int> pi;
pair<WithIntType, float> pf;
deduce_pairs({pi, pi, pi}); // ok
- deduce_pairs({pi, pf, pi}); // FIXME: This should be rejected, as we fail to produce a type that exactly matches the argument type.
+ deduce_pairs({pi, pf, pi}); // expected-error {{no matching function}}
deduce_after_init_list_in_pack((void(*)(int,int))0, {}, 0);
deduce_after_init_list_in_pack((void(*)(int,int))0, {}, 0.0); // expected-error {{no matching function}}
@@ -298,9 +299,18 @@ namespace TemporaryInitListSourceRange_PR22367 {
namespace ParameterPackNestedInitializerLists_PR23904c3 {
template <typename ...T>
- void f(std::initializer_list<std::initializer_list<T>> ...tt);
+ void f(std::initializer_list<std::initializer_list<T>> ...tt); // expected-note 2{{conflicting}} expected-note {{incomplete pack}}
- void foo() { f({{0}}, {{'\0'}}); }
+ void foo() {
+ f({{0}}, {{'\0'}}); // ok, T = <int, char>
+ f({{0}, {'\0'}}); // expected-error {{no match}}
+ f({{0, '\0'}}); // expected-error {{no match}}
+
+ f({{0}}, {{{}}}); // expected-error {{no match}}
+ f({{0}}, {{{}, '\0'}}); // ok, T = <int, char>
+ f({{0}, {{}}}); // ok, T = <int>
+ f({{0, {}}}); // ok, T = <int>
+ }
}
namespace update_rbrace_loc_crash {
@@ -327,3 +337,13 @@ namespace update_rbrace_loc_crash {
Explode<ContainsIncomplete, 4>([](int) {});
}
}
+
+namespace no_conversion_after_auto_list_deduction {
+ // We used to deduce 'auto' == 'std::initializer_list<X>' here, and then
+ // incorrectly accept the declaration of 'x'.
+ struct X { using T = std::initializer_list<X> X::*; operator T(); };
+ auto X::*x = { X() }; // expected-error {{from initializer list}}
+
+ struct Y { using T = std::initializer_list<Y>(*)(); operator T(); };
+ auto (*y)() = { Y() }; // expected-error {{from initializer list}}
+}
diff --git a/test/SemaCXX/cxx1z-decomposition.cpp b/test/SemaCXX/cxx1z-decomposition.cpp
index 735a9e1dfee0..d457ace5d844 100644
--- a/test/SemaCXX/cxx1z-decomposition.cpp
+++ b/test/SemaCXX/cxx1z-decomposition.cpp
@@ -65,4 +65,9 @@ void for_range() {
}
}
+int error_recovery() {
+ auto [foobar]; // expected-error {{requires an initializer}}
+ return foobar_; // expected-error {{undeclared identifier 'foobar_'}}
+}
+
// FIXME: by-value array copies
diff --git a/test/SemaCXX/default-arg-closures.cpp b/test/SemaCXX/default-arg-closures.cpp
index e076cc05cd20..676bd486105f 100644
--- a/test/SemaCXX/default-arg-closures.cpp
+++ b/test/SemaCXX/default-arg-closures.cpp
@@ -4,16 +4,15 @@
// instantiating and checking the semantics of default arguments. Make sure we
// do that right.
-// FIXME: Don't diagnose this issue twice.
template <typename T>
-struct DependentDefaultCtorArg { // expected-note {{in instantiation of default function argument}}
- // expected-error@+1 2 {{type 'int' cannot be used prior to '::' because it has no members}}
+struct DependentDefaultCtorArg {
+ // expected-error@+1 {{type 'int' cannot be used prior to '::' because it has no members}}
DependentDefaultCtorArg(int n = T::error);
};
struct
__declspec(dllexport) // expected-note {{due to 'ExportDefaultCtorClosure' being dllexported}}
-ExportDefaultCtorClosure // expected-note {{implicit default constructor for 'ExportDefaultCtorClosure' first required here}}
-: DependentDefaultCtorArg<int> // expected-note {{in instantiation of template class}}
+ExportDefaultCtorClosure // expected-note {{in instantiation of default function argument expression for 'DependentDefaultCtorArg<int>' required here}} expected-note {{implicit default constructor for 'ExportDefaultCtorClosure' first required here}}
+: DependentDefaultCtorArg<int>
{};
template <typename T>
diff --git a/test/SemaCXX/dllexport.cpp b/test/SemaCXX/dllexport.cpp
index b4850fc03d9b..a3fed70ec958 100644
--- a/test/SemaCXX/dllexport.cpp
+++ b/test/SemaCXX/dllexport.cpp
@@ -741,6 +741,27 @@ struct __declspec(dllexport) ClassWithMultipleDefaultCtors {
ClassWithMultipleDefaultCtors(int = 40) {} // expected-error{{'__declspec(dllexport)' cannot be applied to more than one default constructor}}
ClassWithMultipleDefaultCtors(int = 30, ...) {} // expected-note{{declared here}}
};
+template <typename T>
+struct ClassTemplateWithMultipleDefaultCtors {
+ __declspec(dllexport) ClassTemplateWithMultipleDefaultCtors(int = 40) {} // expected-error{{'__declspec(dllexport)' cannot be applied to more than one default constructor}}
+ __declspec(dllexport) ClassTemplateWithMultipleDefaultCtors(int = 30, ...) {} // expected-note{{declared here}}
+};
+
+template <typename T> struct HasDefaults {
+ HasDefaults(int x = sizeof(T)) {} // expected-error {{invalid application of 'sizeof'}}
+};
+template struct __declspec(dllexport) HasDefaults<char>;
+
+template struct
+__declspec(dllexport) // expected-note {{in instantiation of default function argument expression for 'HasDefaults<void>' required here}}
+HasDefaults<void>; // expected-note {{in instantiation of member function 'HasDefaults<void>::HasDefaults' requested here}}
+
+template <typename T> struct HasDefaults2 {
+ __declspec(dllexport) // expected-note {{in instantiation of default function argument expression for 'HasDefaults2<void>' required here}}
+ HasDefaults2(int x = sizeof(T)) {} // expected-error {{invalid application of 'sizeof'}}
+};
+template struct HasDefaults2<void>; // expected-note {{in instantiation of member function 'HasDefaults2<void>::HasDefaults2' requested here}}
+
#endif
//===----------------------------------------------------------------------===//
diff --git a/test/SemaCXX/type-definition-in-specifier.cpp b/test/SemaCXX/type-definition-in-specifier.cpp
index 74ba058b4f12..2da649fdb0b8 100644
--- a/test/SemaCXX/type-definition-in-specifier.cpp
+++ b/test/SemaCXX/type-definition-in-specifier.cpp
@@ -59,10 +59,8 @@ struct s19018b {
};
struct pr18963 {
- short bar5 (struct foo4 {} bar2); // expected-error{{'foo4' cannot be defined in a parameter type}} \
- // expected-note{{declared here}}
-
- long foo5 (float foo6 = foo4); // expected-error{{'foo4' does not refer to a value}}
+ short bar5 (struct foo4 {} bar2); // expected-error{{'foo4' cannot be defined in a parameter type}}
+ long foo5 (float foo6 = foo4);
};
// expected-error@+2 {{cannot be defined in a parameter type}}