aboutsummaryrefslogtreecommitdiff
path: root/test/SemaTemplate
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2012-12-02 13:20:44 +0000
committerDimitry Andric <dim@FreeBSD.org>2012-12-02 13:20:44 +0000
commit13cc256e404620c1de0cbcc4e43ce1e2dbbc4898 (patch)
tree2732d02d7d51218d6eed98ac7fcfc5b8794896b5 /test/SemaTemplate
parent657bc3d9848e3be92029b2416031340988cd0111 (diff)
downloadsrc-13cc256e404620c1de0cbcc4e43ce1e2dbbc4898.tar.gz
src-13cc256e404620c1de0cbcc4e43ce1e2dbbc4898.zip
Vendor import of clang release_32 branch r168974 (effectively, 3.2 RC2):vendor/clang/clang-release_32-r168974
Notes
Notes: svn path=/vendor/clang/dist/; revision=243791 svn path=/vendor/clang/clang-release_32-r168974/; revision=243792; tag=vendor/clang/clang-release_32-r168974
Diffstat (limited to 'test/SemaTemplate')
-rw-r--r--test/SemaTemplate/ackermann.cpp1
-rw-r--r--test/SemaTemplate/alias-church-numerals.cpp1
-rw-r--r--test/SemaTemplate/alias-template-template-param.cpp1
-rw-r--r--test/SemaTemplate/array-to-pointer-decay.cpp1
-rw-r--r--test/SemaTemplate/atomics.cpp1
-rw-r--r--test/SemaTemplate/class-template-ctor-initializer.cpp17
-rw-r--r--test/SemaTemplate/class-template-id.cpp2
-rw-r--r--test/SemaTemplate/constexpr-instantiate.cpp133
-rw-r--r--test/SemaTemplate/current-instantiation.cpp14
-rw-r--r--test/SemaTemplate/deduction-crash.cpp25
-rw-r--r--test/SemaTemplate/default-arguments-cxx0x.cpp1
-rw-r--r--test/SemaTemplate/dependent-base-member-init.cpp1
-rw-r--r--test/SemaTemplate/dependent-expr.cpp1
-rw-r--r--test/SemaTemplate/dependent-names.cpp26
-rw-r--r--test/SemaTemplate/dependent-sized_array.cpp11
-rw-r--r--test/SemaTemplate/derived.cpp12
-rw-r--r--test/SemaTemplate/enum-argument.cpp1
-rw-r--r--test/SemaTemplate/example-typelist.cpp1
-rw-r--r--test/SemaTemplate/inject-templated-friend-post.cpp8
-rw-r--r--test/SemaTemplate/instantiate-array.cpp1
-rw-r--r--test/SemaTemplate/instantiate-attr.cpp10
-rw-r--r--test/SemaTemplate/instantiate-decl-init.cpp1
-rw-r--r--test/SemaTemplate/instantiate-declref-ice.cpp1
-rw-r--r--test/SemaTemplate/instantiate-deeply.cpp1
-rw-r--r--test/SemaTemplate/instantiate-dependent-nested-name.cpp1
-rw-r--r--test/SemaTemplate/instantiate-elab-type-specifier.cpp1
-rw-r--r--test/SemaTemplate/instantiate-enum-2.cpp1
-rw-r--r--test/SemaTemplate/instantiate-exception-spec-cxx11.cpp12
-rw-r--r--test/SemaTemplate/instantiate-friend-class.cpp1
-rw-r--r--test/SemaTemplate/instantiate-local-class.cpp1
-rw-r--r--test/SemaTemplate/instantiate-member-expr.cpp17
-rw-r--r--test/SemaTemplate/instantiate-non-type-template-parameter.cpp1
-rw-r--r--test/SemaTemplate/instantiate-overload-candidates.cpp30
-rw-r--r--test/SemaTemplate/instantiate-overloaded-arrow.cpp1
-rw-r--r--test/SemaTemplate/instantiate-sizeof.cpp1
-rw-r--r--test/SemaTemplate/instantiation-default-3.cpp1
-rw-r--r--test/SemaTemplate/instantiation-depth-exception-spec.cpp11
-rw-r--r--test/SemaTemplate/instantiation-depth-subst-2.cpp7
-rw-r--r--test/SemaTemplate/instantiation-depth-subst.cpp6
-rw-r--r--test/SemaTemplate/issue150.cpp1
-rw-r--r--test/SemaTemplate/lookup-dependent-bases.cpp1
-rw-r--r--test/SemaTemplate/member-access-ambig.cpp21
-rw-r--r--test/SemaTemplate/member-initializers.cpp1
-rw-r--r--test/SemaTemplate/nested-linkage.cpp1
-rw-r--r--test/SemaTemplate/nested-template.cpp5
-rw-r--r--test/SemaTemplate/operator-function-id-template.cpp1
-rw-r--r--test/SemaTemplate/overload-uneval.cpp1
-rw-r--r--test/SemaTemplate/pragma-ms_struct.cpp1
-rw-r--r--test/SemaTemplate/temp_class_spec_blocks.cpp1
-rw-r--r--test/SemaTemplate/template-class-traits.cpp1
-rw-r--r--test/SemaTemplate/typo-dependent-name.cpp1
-rw-r--r--test/SemaTemplate/unresolved-construct.cpp1
52 files changed, 370 insertions, 31 deletions
diff --git a/test/SemaTemplate/ackermann.cpp b/test/SemaTemplate/ackermann.cpp
index 9525bfcc4f43..fc523e392eaf 100644
--- a/test/SemaTemplate/ackermann.cpp
+++ b/test/SemaTemplate/ackermann.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
// template<unsigned M, unsigned N>
// struct Ackermann {
diff --git a/test/SemaTemplate/alias-church-numerals.cpp b/test/SemaTemplate/alias-church-numerals.cpp
index 69d77163ab67..a1613230ac0d 100644
--- a/test/SemaTemplate/alias-church-numerals.cpp
+++ b/test/SemaTemplate/alias-church-numerals.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+// expected-no-diagnostics
template<template<template<typename> class, typename> class T, template<typename> class V> struct PartialApply {
template<typename W> using R = T<V, W>;
diff --git a/test/SemaTemplate/alias-template-template-param.cpp b/test/SemaTemplate/alias-template-template-param.cpp
index c22fccb6788e..0b17d10d0cb6 100644
--- a/test/SemaTemplate/alias-template-template-param.cpp
+++ b/test/SemaTemplate/alias-template-template-param.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// expected-no-diagnostics
template<template<typename> class D> using C = D<int>;
diff --git a/test/SemaTemplate/array-to-pointer-decay.cpp b/test/SemaTemplate/array-to-pointer-decay.cpp
index 072c0e52edc6..26d277d7dc05 100644
--- a/test/SemaTemplate/array-to-pointer-decay.cpp
+++ b/test/SemaTemplate/array-to-pointer-decay.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
struct mystruct {
int member;
diff --git a/test/SemaTemplate/atomics.cpp b/test/SemaTemplate/atomics.cpp
index e9fdc9de3d23..19b607f738a8 100644
--- a/test/SemaTemplate/atomics.cpp
+++ b/test/SemaTemplate/atomics.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
// PR8345
template<typename T> T f(T* value) {
diff --git a/test/SemaTemplate/class-template-ctor-initializer.cpp b/test/SemaTemplate/class-template-ctor-initializer.cpp
index 44bb4bda791e..6043327b7bab 100644
--- a/test/SemaTemplate/class-template-ctor-initializer.cpp
+++ b/test/SemaTemplate/class-template-ctor-initializer.cpp
@@ -53,3 +53,20 @@ namespace PR7259 {
return 0;
}
}
+
+namespace NonDependentError {
+ struct Base { Base(int); }; // expected-note 2{{candidate}}
+
+ template<typename T>
+ struct Derived1 : Base {
+ Derived1() : Base(1, 2) {} // expected-error {{no matching constructor}}
+ };
+
+ template<typename T>
+ struct Derived2 : Base {
+ Derived2() : BaseClass(1) {} // expected-error {{does not name a non-static data member or base}}
+ };
+
+ Derived1<void> d1;
+ Derived2<void> d2;
+}
diff --git a/test/SemaTemplate/class-template-id.cpp b/test/SemaTemplate/class-template-id.cpp
index 3b027787249b..b674537ea71c 100644
--- a/test/SemaTemplate/class-template-id.cpp
+++ b/test/SemaTemplate/class-template-id.cpp
@@ -40,7 +40,7 @@ typedef N::C<float> c2;
// PR5655
template<typename T> struct Foo { }; // expected-note{{template is declared here}}
-void f(void) { Foo bar; } // expected-error{{without a template argument list}}
+void f(void) { Foo bar; } // expected-error{{use of class template Foo requires template arguments}}
// rdar://problem/8254267
template <typename T> class Party;
diff --git a/test/SemaTemplate/constexpr-instantiate.cpp b/test/SemaTemplate/constexpr-instantiate.cpp
index 2f9fe0e4855b..80c4aaf85601 100644
--- a/test/SemaTemplate/constexpr-instantiate.cpp
+++ b/test/SemaTemplate/constexpr-instantiate.cpp
@@ -75,3 +75,136 @@ namespace Reference {
constexpr int n = const_cast<int&>(S<int>::r);
static_assert(n == 5, "");
}
+
+namespace Unevaluated {
+ // We follow g++ in treating any reference to a constexpr function template
+ // specialization as requiring an instantiation, even if it occurs in an
+ // unevaluated context.
+ //
+ // We go slightly further than g++, and also trigger the implicit definition
+ // of a defaulted special member in the same circumstances. This seems scary,
+ // since a lot of classes have constexpr special members in C++11, but the
+ // only observable impact should be the implicit instantiation of constexpr
+ // special member templates (defaulted special members should only be
+ // generated if they are well-formed, and non-constexpr special members in a
+ // base or member cause the class's special member to not be constexpr).
+ //
+ // FIXME: None of this is required by the C++ standard. The rules in this
+ // area are poorly specified, so this is subject to change.
+ namespace NotConstexpr {
+ template<typename T> struct S {
+ S() : n(0) {}
+ S(const S&) : n(T::error) {}
+ int n;
+ };
+ struct U : S<int> {};
+ decltype(U(U())) u; // ok, don't instantiate S<int>::S() because it wasn't declared constexpr
+ }
+ namespace Constexpr {
+ template<typename T> struct S {
+ constexpr S() : n(0) {}
+ constexpr S(const S&) : n(T::error) {} // expected-error {{has no members}}
+ int n;
+ };
+ struct U : S<int> {}; // expected-note {{instantiation}}
+ decltype(U(U())) u; // expected-note {{here}}
+ }
+
+ namespace PR11851_Comment0 {
+ template<int x> constexpr int f() { return x; }
+ template<int i> void ovf(int (&x)[f<i>()]);
+ void f() { int x[10]; ovf<10>(x); }
+ }
+
+ namespace PR11851_Comment1 {
+ template<typename T>
+ constexpr bool Integral() {
+ return true;
+ }
+ template<typename T, bool Int = Integral<T>()>
+ struct safe_make_unsigned {
+ typedef T type;
+ };
+ template<typename T>
+ using Make_unsigned = typename safe_make_unsigned<T>::type;
+ template <typename T>
+ struct get_distance_type {
+ using type = int;
+ };
+ template<typename R>
+ auto size(R) -> Make_unsigned<typename get_distance_type<R>::type>;
+ auto check() -> decltype(size(0));
+ }
+
+ namespace PR11851_Comment6 {
+ template<int> struct foo {};
+ template<class> constexpr int bar() { return 0; }
+ template<class T> foo<bar<T>()> foobar();
+ auto foobar_ = foobar<int>();
+ }
+
+ namespace PR11851_Comment9 {
+ struct S1 {
+ constexpr S1() {}
+ constexpr operator int() const { return 0; }
+ };
+ int k1 = sizeof(short{S1(S1())});
+
+ struct S2 {
+ constexpr S2() {}
+ constexpr operator int() const { return 123456; }
+ };
+ int k2 = sizeof(short{S2(S2())}); // expected-error {{cannot be narrowed}} expected-note {{override}}
+ }
+
+ namespace PR12288 {
+ template <typename> constexpr bool foo() { return true; }
+ template <bool> struct bar {};
+ template <typename T> bar<foo<T>()> baz() { return bar<foo<T>()>(); }
+ int main() { baz<int>(); }
+ }
+
+ namespace PR13423 {
+ template<bool, typename> struct enable_if {};
+ template<typename T> struct enable_if<true, T> { using type = T; };
+
+ template<typename T> struct F {
+ template<typename U>
+ static constexpr bool f() { return sizeof(T) < U::size; }
+
+ template<typename U>
+ static typename enable_if<f<U>(), void>::type g() {} // expected-note {{disabled by 'enable_if'}}
+ };
+
+ struct U { static constexpr int size = 2; };
+
+ void h() { F<char>::g<U>(); }
+ void i() { F<int>::g<U>(); } // expected-error {{no matching function}}
+ }
+
+ namespace PR14203 {
+ struct duration { constexpr duration() {} };
+
+ template <typename>
+ void sleep_for() {
+ constexpr duration max = duration();
+ }
+ }
+}
+
+namespace NoInstantiationWhenSelectingOverload {
+ // Check that we don't instantiate conversion functions when we're checking
+ // for the existence of an implicit conversion sequence, only when a function
+ // is actually chosen by overload resolution.
+ struct S {
+ template<typename T> constexpr S(T) : n(T::error) {} // expected-error {{no members}}
+ int n;
+ };
+
+ void f(S);
+ void f(int);
+
+ void g() { f(0); }
+ void h() { (void)sizeof(f(0)); }
+ void i() { (void)sizeof(f("oops")); } // expected-note {{instantiation of}}
+}
diff --git a/test/SemaTemplate/current-instantiation.cpp b/test/SemaTemplate/current-instantiation.cpp
index ccef811e2224..f47c07187cb2 100644
--- a/test/SemaTemplate/current-instantiation.cpp
+++ b/test/SemaTemplate/current-instantiation.cpp
@@ -2,7 +2,7 @@
// This test concerns the identity of dependent types within the
// canonical type system, specifically focusing on the difference
-// between members of the current instantiation and membmers of an
+// between members of the current instantiation and members of an
// unknown specialization. This considers C++ [temp.type], which
// specifies type equivalence within a template, and C++0x
// [temp.dep.type], which defines what it means to be a member of the
@@ -235,3 +235,15 @@ namespace rdar10194295 {
template<typename X<XT>::Enum>
class X<XT>::Inner { };
}
+
+namespace RebuildDependentScopeDeclRefExpr {
+ template<int> struct N {};
+ template<typename T> struct X {
+ static const int thing = 0;
+ N<thing> data();
+ N<thing> foo();
+ };
+ template<typename T> N<X<T>::thing> X<T>::data() {}
+ // FIXME: We should issue a typo-correction here.
+ template<typename T> N<X<T>::think> X<T>::foo() {} // expected-error {{no member named 'think' in 'X<T>'}}
+}
diff --git a/test/SemaTemplate/deduction-crash.cpp b/test/SemaTemplate/deduction-crash.cpp
index cf3899f5eda7..0714c5e51648 100644
--- a/test/SemaTemplate/deduction-crash.cpp
+++ b/test/SemaTemplate/deduction-crash.cpp
@@ -2,7 +2,7 @@
// Note that the error count below doesn't matter. We just want to
// make sure that the parser doesn't crash.
-// CHECK: 13 errors
+// CHECK: 15 errors
// PR7511
template<a>
@@ -87,3 +87,26 @@ void register_object_imp ( )
{
cout << endl<1>;
}
+
+// PR12933
+namespacae PR12933 {
+ template<typename S>
+ template<typename T>
+ void function(S a, T b) {}
+
+ int main() {
+ function(0, 1);
+ return 0;
+ }
+}
+
+// A buildbot failure from libcxx
+namespace libcxx_test {
+ template <class _Ptr, bool> struct __pointer_traits_element_type;
+ template <class _Ptr> struct __pointer_traits_element_type<_Ptr, true>;
+ template <template <class, class...> class _Sp, class _Tp, class ..._Args> struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, true> {
+ typedef char type;
+ };
+ template <class T> struct B {};
+ __pointer_traits_element_type<B<int>, true>::type x;
+}
diff --git a/test/SemaTemplate/default-arguments-cxx0x.cpp b/test/SemaTemplate/default-arguments-cxx0x.cpp
index 77143136c3d2..4c815f655875 100644
--- a/test/SemaTemplate/default-arguments-cxx0x.cpp
+++ b/test/SemaTemplate/default-arguments-cxx0x.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+// expected-no-diagnostics
// Test default template arguments for function templates.
template<typename T = int>
diff --git a/test/SemaTemplate/dependent-base-member-init.cpp b/test/SemaTemplate/dependent-base-member-init.cpp
index 1d4fed3e1d26..a278e79f9123 100644
--- a/test/SemaTemplate/dependent-base-member-init.cpp
+++ b/test/SemaTemplate/dependent-base-member-init.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
// PR4381
template<class T> struct X {};
diff --git a/test/SemaTemplate/dependent-expr.cpp b/test/SemaTemplate/dependent-expr.cpp
index a1ddd249f7fe..d75b0f3e3029 100644
--- a/test/SemaTemplate/dependent-expr.cpp
+++ b/test/SemaTemplate/dependent-expr.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
// PR5908
template <typename Iterator>
diff --git a/test/SemaTemplate/dependent-names.cpp b/test/SemaTemplate/dependent-names.cpp
index 924bad9257b9..efa4d28723d8 100644
--- a/test/SemaTemplate/dependent-names.cpp
+++ b/test/SemaTemplate/dependent-names.cpp
@@ -319,8 +319,30 @@ namespace PR11421 {
template < unsigned > struct X {
static const unsigned dimension = 3;
template<unsigned dim=dimension>
- struct Y: Y<dim> { }; // expected-error {{incomplete type}} expected-note {{is not complete until the closing}}
+ struct Y: Y<dim> { }; // expected-error{{circular inheritance between 'Y<dim>' and 'Y<dim>'}}
};
typedef X<3> X3;
-X3::Y<>::iterator it; // expected-note {{requested here}}
+X3::Y<>::iterator it; // expected-error {{no type named 'iterator' in 'PR11421::X<3>::Y<3>'}}
+}
+
+namespace rdar12629723 {
+ template<class T>
+ struct X {
+ struct C : public C { }; // expected-error{{circular inheritance between 'rdar12629723::X::C' and 'rdar12629723::X::C'}}
+
+ struct B;
+
+ struct A : public B { // expected-note{{'rdar12629723::X::A' declared here}}
+ virtual void foo() { }
+ };
+ struct B;
+
+ struct D : T::foo { };
+ struct E : D { };
+ };
+
+ template<class T>
+ struct X<T>::B : public A { // expected-error{{circular inheritance between 'rdar12629723::X::A' and 'rdar12629723::X::B'}}
+ virtual void foo() { }
+ };
}
diff --git a/test/SemaTemplate/dependent-sized_array.cpp b/test/SemaTemplate/dependent-sized_array.cpp
index cf0e0f37ee04..6fdcaa63e5ad 100644
--- a/test/SemaTemplate/dependent-sized_array.cpp
+++ b/test/SemaTemplate/dependent-sized_array.cpp
@@ -15,3 +15,14 @@ void f1() {
int a1[] = { 1, 2, 3, N };
int a3[sizeof(a1)/sizeof(int) != 4? 1 : -1]; // expected-error{{negative}}
}
+
+namespace PR13788 {
+ template <unsigned __N>
+ struct S {
+ int V;
+ };
+ template <int N>
+ void foo() {
+ S<0> arr[N] = {{ 4 }};
+ }
+}
diff --git a/test/SemaTemplate/derived.cpp b/test/SemaTemplate/derived.cpp
new file mode 100644
index 000000000000..1fb9401c94c2
--- /dev/null
+++ b/test/SemaTemplate/derived.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T> class vector2 {};
+template<typename T> class vector : vector2<T> {};
+
+template<typename T> void Foo2(vector2<const T*> V) {} // expected-note{{candidate template ignored: can't deduce a type for 'T' which would make 'const T' equal 'int'}}
+template<typename T> void Foo(vector<const T*> V) {} // expected-note {{candidate template ignored: can't deduce a type for 'T' which would make 'const T' equal 'int'}}
+
+void test() {
+ Foo2(vector2<int*>()); // expected-error{{no matching function for call to 'Foo2'}}
+ Foo(vector<int*>()); // expected-error{{no matching function for call to 'Foo'}}
+}
diff --git a/test/SemaTemplate/enum-argument.cpp b/test/SemaTemplate/enum-argument.cpp
index 7d237570678f..7ff419613990 100644
--- a/test/SemaTemplate/enum-argument.cpp
+++ b/test/SemaTemplate/enum-argument.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
enum Enum { val = 1 };
template <Enum v> struct C {
diff --git a/test/SemaTemplate/example-typelist.cpp b/test/SemaTemplate/example-typelist.cpp
index 082aeb83fbdd..9ce06e665cf7 100644
--- a/test/SemaTemplate/example-typelist.cpp
+++ b/test/SemaTemplate/example-typelist.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
// A simple cons-style typelist
struct nil { };
diff --git a/test/SemaTemplate/inject-templated-friend-post.cpp b/test/SemaTemplate/inject-templated-friend-post.cpp
index 39c445ca0f99..c86f718bb5f1 100644
--- a/test/SemaTemplate/inject-templated-friend-post.cpp
+++ b/test/SemaTemplate/inject-templated-friend-post.cpp
@@ -1,7 +1,7 @@
-// RUN: %clang %s -S -emit-llvm -o - | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE"
-// RUN: %clang %s -S -emit-llvm -o - -DPROTOTYPE | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE"
-// RUN: %clang %s -S -emit-llvm -o - -DINSTANTIATE | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE"
-// RUN: %clang %s -S -emit-llvm -o - -DPROTOTYPE -DINSTANTIATE | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE"
+// RUN: %clang %s -std=c++98 -S -emit-llvm -o - | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE"
+// RUN: %clang %s -std=c++98 -S -emit-llvm -o - -DPROTOTYPE | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE"
+// RUN: %clang %s -std=c++98 -S -emit-llvm -o - -DINSTANTIATE | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE"
+// RUN: %clang %s -std=c++98 -S -emit-llvm -o - -DPROTOTYPE -DINSTANTIATE | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE"
// RUN: %clang_cc1 %s -DREDEFINE -verify
// RUN: %clang_cc1 %s -DPROTOTYPE -DREDEFINE -verify
// PR8007: friend function not instantiated, reordered version.
diff --git a/test/SemaTemplate/instantiate-array.cpp b/test/SemaTemplate/instantiate-array.cpp
index b8229d3f641a..41d1cfe138ab 100644
--- a/test/SemaTemplate/instantiate-array.cpp
+++ b/test/SemaTemplate/instantiate-array.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+// expected-no-diagnostics
#ifndef __GXX_EXPERIMENTAL_CXX0X__
#define __CONCAT(__X, __Y) __CONCAT1(__X, __Y)
diff --git a/test/SemaTemplate/instantiate-attr.cpp b/test/SemaTemplate/instantiate-attr.cpp
index bbadb6375b5b..1e94614f371d 100644
--- a/test/SemaTemplate/instantiate-attr.cpp
+++ b/test/SemaTemplate/instantiate-attr.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
template <typename T>
struct A {
char a __attribute__((aligned(16)));
@@ -24,3 +25,12 @@ namespace test1 {
int test1[__builtin_offsetof(type, a) == 0 ? 1 : -1];
int test2[__builtin_offsetof(type, b) == 4 ? 1 : -1];
}
+
+namespace test2 {
+ template <class type>
+ struct fastscriptmember {
+ type Member __attribute__ ((packed));
+ char x;
+ };
+ int test0[sizeof(fastscriptmember<int>) == 5 ? 1 : -1];
+}
diff --git a/test/SemaTemplate/instantiate-decl-init.cpp b/test/SemaTemplate/instantiate-decl-init.cpp
index 6b76d72e3261..9658fc1465cd 100644
--- a/test/SemaTemplate/instantiate-decl-init.cpp
+++ b/test/SemaTemplate/instantiate-decl-init.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
// PR5426 - the non-dependent obj would be fully processed and wrapped in a
// CXXConstructExpr at definition time, which would lead to a failure at
diff --git a/test/SemaTemplate/instantiate-declref-ice.cpp b/test/SemaTemplate/instantiate-declref-ice.cpp
index 49b1b63f5152..7cdeda6fb9da 100644
--- a/test/SemaTemplate/instantiate-declref-ice.cpp
+++ b/test/SemaTemplate/instantiate-declref-ice.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
template<int i> struct x {
static const int j = i;
x<j>* y;
diff --git a/test/SemaTemplate/instantiate-deeply.cpp b/test/SemaTemplate/instantiate-deeply.cpp
index c5f65945afcb..ba38b2b2351c 100644
--- a/test/SemaTemplate/instantiate-deeply.cpp
+++ b/test/SemaTemplate/instantiate-deeply.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -Wall -verify %s
+// expected-no-diagnostics
template<typename a> struct A {
template <typename b> struct B {
template <typename c> struct C {
diff --git a/test/SemaTemplate/instantiate-dependent-nested-name.cpp b/test/SemaTemplate/instantiate-dependent-nested-name.cpp
index eb1d3fba10ed..06a1ed4119d2 100644
--- a/test/SemaTemplate/instantiate-dependent-nested-name.cpp
+++ b/test/SemaTemplate/instantiate-dependent-nested-name.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
// PR4382
template<typename T> struct X { static const T A = 1; };
template<typename T, bool = X<T>::A> struct Y { typedef T A; };
diff --git a/test/SemaTemplate/instantiate-elab-type-specifier.cpp b/test/SemaTemplate/instantiate-elab-type-specifier.cpp
index e5e10a85cf2f..5db9b56c21a4 100644
--- a/test/SemaTemplate/instantiate-elab-type-specifier.cpp
+++ b/test/SemaTemplate/instantiate-elab-type-specifier.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
// PR5681
template <class T> struct Base {
diff --git a/test/SemaTemplate/instantiate-enum-2.cpp b/test/SemaTemplate/instantiate-enum-2.cpp
index aa3b590cada4..9a90a9cd6ce7 100644
--- a/test/SemaTemplate/instantiate-enum-2.cpp
+++ b/test/SemaTemplate/instantiate-enum-2.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 %s -fsyntax-only -verify
+// expected-no-diagnostics
template<int IntBits> struct X {
enum {
diff --git a/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp b/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp
index c560c6ba2a3b..97bf00303bbe 100644
--- a/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp
+++ b/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp
@@ -34,18 +34,6 @@ template<> struct S<10> {};
void (*pFn2)() noexcept = &S<0>::recurse; // expected-note {{instantiation of exception spec}} expected-error {{not superset}}
-template<typename T> T go(T a) noexcept(noexcept(go(a))); // \
-// expected-error 16{{call to function 'go' that is neither visible}} \
-// expected-note 16{{'go' should be declared prior to the call site}} \
-// expected-error {{recursive template instantiation exceeded maximum depth of 16}} \
-// expected-error {{use of undeclared identifier 'go'}} \
-
-void f() {
- int k = go(0); // \
- // expected-note {{in instantiation of exception specification for 'go<int>' requested here}}
-}
-
-
namespace dr1330_example {
template <class T> struct A {
void f(...) throw (typename T::X); // expected-error {{'int'}}
diff --git a/test/SemaTemplate/instantiate-friend-class.cpp b/test/SemaTemplate/instantiate-friend-class.cpp
index c87b8d0bf9b2..32aa3014b9cb 100644
--- a/test/SemaTemplate/instantiate-friend-class.cpp
+++ b/test/SemaTemplate/instantiate-friend-class.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
// PR4794
template <class T> class X
diff --git a/test/SemaTemplate/instantiate-local-class.cpp b/test/SemaTemplate/instantiate-local-class.cpp
index 20b62c1e537e..c151fbb9a5ba 100644
--- a/test/SemaTemplate/instantiate-local-class.cpp
+++ b/test/SemaTemplate/instantiate-local-class.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -verify %s
+// expected-no-diagnostics
template<typename T>
void f0() {
struct X;
diff --git a/test/SemaTemplate/instantiate-member-expr.cpp b/test/SemaTemplate/instantiate-member-expr.cpp
index a31569a0c395..6ba94b28df62 100644
--- a/test/SemaTemplate/instantiate-member-expr.cpp
+++ b/test/SemaTemplate/instantiate-member-expr.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s -pedantic
template<typename T>
struct S {
S() { }
@@ -66,3 +66,18 @@ namespace test2 {
template class B<int>;
}
+
+namespace PR14124 {
+ template<typename T> struct S {
+ int value;
+ };
+ template<typename T> void f() { S<T>::value; } // expected-error {{invalid use of non-static data member 'value'}}
+ template void f<int>(); // expected-note {{in instantiation of}}
+
+ struct List { List *next; };
+ template<typename T, T *(T::*p) = &T::next> struct A {};
+ A<List> a; // ok
+ void operator&(struct Whatever);
+ template<typename T, T *(T::*p) = &T::next> struct B {};
+ B<List> b; // still ok
+}
diff --git a/test/SemaTemplate/instantiate-non-type-template-parameter.cpp b/test/SemaTemplate/instantiate-non-type-template-parameter.cpp
index 027c1e8bb769..04975e30448b 100644
--- a/test/SemaTemplate/instantiate-non-type-template-parameter.cpp
+++ b/test/SemaTemplate/instantiate-non-type-template-parameter.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
// PR5311
template<typename T>
diff --git a/test/SemaTemplate/instantiate-overload-candidates.cpp b/test/SemaTemplate/instantiate-overload-candidates.cpp
index 5b7e60dccfdd..7542dbd8ab9b 100644
--- a/test/SemaTemplate/instantiate-overload-candidates.cpp
+++ b/test/SemaTemplate/instantiate-overload-candidates.cpp
@@ -19,3 +19,33 @@ template <typename T> S_<NoDefinition>::type f(T*, NoDefinition*); // expected-n
void test(int x) {
f(&x, 0);
}
+
+// Ensure that we instantiate an overloaded function if it's selected by
+// overload resolution when initializing a function pointer.
+template<typename T> struct X {
+ static T f() { T::error; } // expected-error {{has no members}}
+ static T f(bool);
+};
+void (*p)() = &X<void>().f; // expected-note {{instantiation of}}
+
+namespace PR13098 {
+ struct A {
+ A(int);
+ void operator++() {}
+ void operator+(int) {}
+ void operator+(A) {}
+ void operator[](int) {}
+ void operator[](A) {}
+ };
+ struct B : A {
+ using A::operator++;
+ using A::operator+;
+ using A::operator[];
+ };
+ template<typename T> void f(B b) {
+ ++b;
+ b + 0;
+ b[0];
+ }
+ template void f<void>(B);
+}
diff --git a/test/SemaTemplate/instantiate-overloaded-arrow.cpp b/test/SemaTemplate/instantiate-overloaded-arrow.cpp
index ee36427db87b..b21c7a34ad4c 100644
--- a/test/SemaTemplate/instantiate-overloaded-arrow.cpp
+++ b/test/SemaTemplate/instantiate-overloaded-arrow.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
// PR5488
struct X {
diff --git a/test/SemaTemplate/instantiate-sizeof.cpp b/test/SemaTemplate/instantiate-sizeof.cpp
index 00d63d0c2fe5..bf66fdc17c65 100644
--- a/test/SemaTemplate/instantiate-sizeof.cpp
+++ b/test/SemaTemplate/instantiate-sizeof.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// expected-no-diagnostics
// Make sure we handle contexts correctly with sizeof
template<typename T> void f(T n) {
diff --git a/test/SemaTemplate/instantiation-default-3.cpp b/test/SemaTemplate/instantiation-default-3.cpp
index dae6b18f32c2..76189ea90bfb 100644
--- a/test/SemaTemplate/instantiation-default-3.cpp
+++ b/test/SemaTemplate/instantiation-default-3.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
template<typename T> struct A { };
diff --git a/test/SemaTemplate/instantiation-depth-exception-spec.cpp b/test/SemaTemplate/instantiation-depth-exception-spec.cpp
new file mode 100644
index 000000000000..6caa4a60e6f8
--- /dev/null
+++ b/test/SemaTemplate/instantiation-depth-exception-spec.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -ftemplate-depth 16 -fcxx-exceptions -fexceptions %s
+
+template<typename T> T go(T a) noexcept(noexcept(go(a))); // \
+// expected-error 16{{call to function 'go' that is neither visible}} \
+// expected-note 16{{'go' should be declared prior to the call site}} \
+// expected-error {{recursive template instantiation exceeded maximum depth of 16}}
+
+void f() {
+ int k = go(0); // \
+ // expected-note {{in instantiation of exception specification for 'go<int>' requested here}}
+}
diff --git a/test/SemaTemplate/instantiation-depth-subst-2.cpp b/test/SemaTemplate/instantiation-depth-subst-2.cpp
index a29d6b5a1b4c..ef2a5c765d9c 100644
--- a/test/SemaTemplate/instantiation-depth-subst-2.cpp
+++ b/test/SemaTemplate/instantiation-depth-subst-2.cpp
@@ -1,9 +1,6 @@
// RUN: %clang_cc1 -verify %s -ftemplate-depth 2
template<int N> struct S { };
-// FIXME: We produce the same 'instantiation depth' error here many times
-// (2^(depth+1) in total), due to additional lookups performed as part of
-// error recovery in DiagnoseTwoPhaseOperatorLookup.
-template<typename T> S<T() + T()> operator+(T, T); // expected-error 8{{}} expected-note 10{{}}
+template<typename T> S<T() + T()> operator+(T, T); // expected-error {{instantiation exceeded maximum depth}} expected-note 3{{while substituting}}
S<0> s;
-int k = s + s; // expected-error {{invalid operands to binary expression}}
+int k = s + s;
diff --git a/test/SemaTemplate/instantiation-depth-subst.cpp b/test/SemaTemplate/instantiation-depth-subst.cpp
index 58e637411c66..06795f9514d3 100644
--- a/test/SemaTemplate/instantiation-depth-subst.cpp
+++ b/test/SemaTemplate/instantiation-depth-subst.cpp
@@ -3,7 +3,7 @@
// PR9793
template<typename T> auto f(T t) -> decltype(f(t)); // \
// expected-error {{recursive template instantiation exceeded maximum depth of 2}} \
-// expected-note 3 {{while substituting}} \
-// expected-note {{candidate}}
+// expected-note 3 {{while substituting}}
-int k = f(0); // expected-error {{no matching function for call to 'f'}}
+struct S {};
+int k = f(S{});
diff --git a/test/SemaTemplate/issue150.cpp b/test/SemaTemplate/issue150.cpp
index af3b93c907c1..a04be35a29e7 100644
--- a/test/SemaTemplate/issue150.cpp
+++ b/test/SemaTemplate/issue150.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
// Core issue 150: Template template parameters and default arguments
diff --git a/test/SemaTemplate/lookup-dependent-bases.cpp b/test/SemaTemplate/lookup-dependent-bases.cpp
index 2710caf22125..4fcfbd196407 100644
--- a/test/SemaTemplate/lookup-dependent-bases.cpp
+++ b/test/SemaTemplate/lookup-dependent-bases.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fms-extensions -fsyntax-only -verify %s
+// expected-no-diagnostics
class C {
public:
diff --git a/test/SemaTemplate/member-access-ambig.cpp b/test/SemaTemplate/member-access-ambig.cpp
index f8a01d5fff2a..5c2d7617033f 100644
--- a/test/SemaTemplate/member-access-ambig.cpp
+++ b/test/SemaTemplate/member-access-ambig.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-unused-comparison %s
// PR8439
class A
@@ -43,3 +43,22 @@ namespace PR11134 {
};
}
+namespace AddrOfMember {
+ struct A { int X; };
+ typedef int (A::*P);
+ template<typename T> struct S : T {
+ void f() {
+ P(&T::X) // expected-error {{cannot cast from type 'int *' to member pointer type 'P'}}
+ == &A::X;
+ }
+ };
+
+ void g() {
+ S<A>().f(); // ok, &T::X is 'int (A::*)', not 'int *', even though T is a base class
+ }
+
+ struct B : A { static int X; };
+ void h() {
+ S<B>().f(); // expected-note {{here}}
+ }
+}
diff --git a/test/SemaTemplate/member-initializers.cpp b/test/SemaTemplate/member-initializers.cpp
index 40f56b34dae0..6791048874f8 100644
--- a/test/SemaTemplate/member-initializers.cpp
+++ b/test/SemaTemplate/member-initializers.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
template<typename T> struct A {
A() : j(10), i(10) { }
diff --git a/test/SemaTemplate/nested-linkage.cpp b/test/SemaTemplate/nested-linkage.cpp
index 6c0791c2efc8..59746ea9c10e 100644
--- a/test/SemaTemplate/nested-linkage.cpp
+++ b/test/SemaTemplate/nested-linkage.cpp
@@ -1,3 +1,4 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
extern "C" { extern "C++" { template<class C> C x(); } }
diff --git a/test/SemaTemplate/nested-template.cpp b/test/SemaTemplate/nested-template.cpp
index 7849bae4d571..47502536caf7 100644
--- a/test/SemaTemplate/nested-template.cpp
+++ b/test/SemaTemplate/nested-template.cpp
@@ -155,3 +155,8 @@ namespace PR10924 {
{
};
}
+
+class Outer1 {
+ template <typename T> struct X;
+ template <typename T> int X<T>::func() {} // expected-error{{out-of-line definition of 'func' from class 'X<T>' without definition}}
+};
diff --git a/test/SemaTemplate/operator-function-id-template.cpp b/test/SemaTemplate/operator-function-id-template.cpp
index 9a0884e8136d..96dfe26cc596 100644
--- a/test/SemaTemplate/operator-function-id-template.cpp
+++ b/test/SemaTemplate/operator-function-id-template.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
template<typename T>
struct A {
diff --git a/test/SemaTemplate/overload-uneval.cpp b/test/SemaTemplate/overload-uneval.cpp
index 8d8a2f42cf28..c952ef8ec7c4 100644
--- a/test/SemaTemplate/overload-uneval.cpp
+++ b/test/SemaTemplate/overload-uneval.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify -Wno-unused %s
+// expected-no-diagnostics
// Tests that overload resolution is treated as an unevaluated context.
// PR5541
diff --git a/test/SemaTemplate/pragma-ms_struct.cpp b/test/SemaTemplate/pragma-ms_struct.cpp
index f04dc5ccae45..fe0b494b9a57 100644
--- a/test/SemaTemplate/pragma-ms_struct.cpp
+++ b/test/SemaTemplate/pragma-ms_struct.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-apple-osx10.7.0 %s
+// expected-no-diagnostics
#pragma ms_struct on
diff --git a/test/SemaTemplate/temp_class_spec_blocks.cpp b/test/SemaTemplate/temp_class_spec_blocks.cpp
index b7b96df69ba5..4b99716d582e 100644
--- a/test/SemaTemplate/temp_class_spec_blocks.cpp
+++ b/test/SemaTemplate/temp_class_spec_blocks.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s -fblocks
+// expected-no-diagnostics
template<typename T>
struct is_unary_block {
static const bool value = false;
diff --git a/test/SemaTemplate/template-class-traits.cpp b/test/SemaTemplate/template-class-traits.cpp
index 471029445256..63ce8f434da3 100644
--- a/test/SemaTemplate/template-class-traits.cpp
+++ b/test/SemaTemplate/template-class-traits.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
#define T(b) (b) ? 1 : -1
#define F(b) (b) ? -1 : 1
diff --git a/test/SemaTemplate/typo-dependent-name.cpp b/test/SemaTemplate/typo-dependent-name.cpp
index 96554e9dcf4a..78cedd0c98ca 100644
--- a/test/SemaTemplate/typo-dependent-name.cpp
+++ b/test/SemaTemplate/typo-dependent-name.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
template<typename T>
struct Base {
diff --git a/test/SemaTemplate/unresolved-construct.cpp b/test/SemaTemplate/unresolved-construct.cpp
index bb9ed8e4e081..ef010fbdd174 100644
--- a/test/SemaTemplate/unresolved-construct.cpp
+++ b/test/SemaTemplate/unresolved-construct.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+// expected-no-diagnostics
class A
{
public: