1// RUN: %clang_cc1 -fsyntax-only -verify %s 2 3// Tests that dependent expressions are always allowed, whereas non-dependent 4// are checked as usual. 5 6#include <stddef.h> 7 8// Fake typeid, lacking a typeinfo header. 9namespace std { class type_info {}; } 10 11struct dummy {}; // expected-note 3 {{candidate constructor (the implicit copy constructor)}} 12 13template<typename T> 14int f0(T x) { 15 return (sizeof(x) == sizeof(int))? 0 : (sizeof(x) == sizeof(double))? 1 : 2; 16} 17 18template <typename T, typename U> 19T f1(T t1, U u1, int i1) 20{ 21 T t2 = i1; 22 t2 = i1 + u1; 23 ++u1; 24 u1++; 25 int i2 = u1; 26 27 i1 = t1[u1]; 28 i1 *= t1; 29 30 i1(u1, t1); // error 31 u1(i1, t1); 32 33 U u2 = (T)i1; 34 static_cast<void>(static_cast<U>(reinterpret_cast<T>( 35 dynamic_cast<U>(const_cast<T>(i1))))); 36 37 new U(i1, t1); 38 new int(t1, u1); 39 new (t1, u1) int; 40 delete t1; 41 42 dummy d1 = sizeof(t1); // expected-error {{no viable conversion}} 43 dummy d2 = offsetof(T, foo); // expected-error {{no viable conversion}} 44 dummy d3 = __alignof(u1); // expected-error {{no viable conversion}} 45 i1 = typeid(t1); // expected-error {{assigning to 'int' from incompatible type 'const std::type_info'}} 46 47 return u1; 48} 49