Daniel Dunbar | d7d5f02 | 2009-03-24 02:24:46 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -fsyntax-only -verify %s |
Sebastian Redl | 2850784 | 2009-02-26 14:39:58 +0000 | [diff] [blame] | 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. |
| 9 | namespace std { class type_info {}; } |
| 10 | |
| 11 | struct dummy {}; |
| 12 | |
| 13 | template <typename T, typename U> |
| 14 | T 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 | |
Douglas Gregor | 9ea6276 | 2009-05-21 23:17:49 +0000 | [diff] [blame^] | 37 | dummy d1 = sizeof(t1); // FIXME: delayed checking okay? |
Sebastian Redl | 2850784 | 2009-02-26 14:39:58 +0000 | [diff] [blame] | 38 | dummy d2 = offsetof(T, foo); // expected-error {{cannot initialize 'd2'}} |
Douglas Gregor | 9ea6276 | 2009-05-21 23:17:49 +0000 | [diff] [blame^] | 39 | dummy d3 = __alignof(u1); // FIXME: delayed checking okay? |
Sebastian Redl | 2850784 | 2009-02-26 14:39:58 +0000 | [diff] [blame] | 40 | i1 = typeid(t1); // expected-error {{incompatible type assigning}} |
| 41 | |
| 42 | return u1; |
| 43 | } |