blob: fdcf6ee92cae740c2e31c41e1855075e7996cf6e [file] [log] [blame]
Daniel Dunbard7d5f022009-03-24 02:24:46 +00001// RUN: clang-cc -fsyntax-only -verify %s
Sebastian Redl28507842009-02-26 14:39:58 +00002
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 {};
12
13template <typename T, typename U>
14T f(T t1, U u1, int i1)
15{
16 T t2 = i1;
17 t2 = i1 + u1;
18 ++u1;
19 u1++;
20 int i2 = u1;
21
22 i1 = t1[u1];
23 i1 *= t1;
24
25 i1(u1, t1); // error
26 u1(i1, t1);
27
28 U u2 = (T)i1;
29 static_cast<void>(static_cast<U>(reinterpret_cast<T>(
30 dynamic_cast<U>(const_cast<T>(i1)))));
31
32 new U(i1, t1);
33 new int(t1, u1); // expected-error {{initializer of a builtin type can only take one argument}}
34 new (t1, u1) int;
35 delete t1;
36
37 dummy d1 = sizeof(t1); // expected-error {{cannot initialize 'd1'}}
38 dummy d2 = offsetof(T, foo); // expected-error {{cannot initialize 'd2'}}
39 dummy d3 = __alignof(u1); // expected-error {{cannot initialize 'd3'}}
40 i1 = typeid(t1); // expected-error {{incompatible type assigning}}
41
42 return u1;
43}