diff options
Diffstat (limited to 'test/SemaTemplate')
52 files changed, 370 insertions, 31 deletions
diff --git a/test/SemaTemplate/ackermann.cpp b/test/SemaTemplate/ackermann.cpp index 9525bfc..fc523e3 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 69d7716..a1613230 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 c22fccb..0b17d10 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 072c0e5..26d277d 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 e9fdc9d..19b607f 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 44bb4bd..6043327 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 3b02778..b674537 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 2f9fe0e..80c4aaf 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 ccef811..f47c071 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 cf3899f..0714c5e 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 7714313..4c815f6 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 1d4fed3..a278e79 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 a1ddd24..d75b0f3 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 924bad9..efa4d28 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 cf0e0f3..6fdcaa6 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 0000000..1fb9401 --- /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 7d23757..7ff4196 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 082aeb8..9ce06e6 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 39c445c..c86f718 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 b8229d3..41d1cfe 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 bbadb63..1e94614 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 6b76d72..9658fc1 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 49b1b63..7cdeda6 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 c5f6594..ba38b2b 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 eb1d3fb..06a1ed4 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 e5e10a8..5db9b56 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 aa3b590..9a90a9c 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 c560c6b..97bf003 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 c87b8d0..32aa301 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 20b62c1..c151fbb 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 a31569a..6ba94b2 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 027c1e8..04975e3 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 5b7e60d..7542dbd 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 ee36427..b21c7a3 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 00d63d0..bf66fdc1 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 dae6b18..76189ea 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 0000000..6caa4a6 --- /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 a29d6b5..ef2a5c7 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 58e6374..06795f9 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 af3b93c..a04be35 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 2710caf..4fcfbd1 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 f8a01d5..5c2d761 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 40f56b3..6791048 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 6c0791c..59746ea 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 7849bae..4750253 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 9a0884e..96dfe26 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 8d8a2f4..c952ef8 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 f04dc5c..fe0b494 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 b7b96df..4b99716 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 4710294..63ce8f4 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 96554e9..78cedd0 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 bb9ed8e..ef010fb 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: |