Douglas Gregor | b197572 | 2009-07-30 23:18:24 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -fsyntax-only -verify %s |
| 2 | |
| 3 | void f(); |
| 4 | |
Douglas Gregor | b197572 | 2009-07-30 23:18:24 +0000 | [diff] [blame] | 5 | // Test typeof(expr) canonicalization |
Douglas Gregor | 4a3f780 | 2009-07-31 15:45:02 +0000 | [diff] [blame] | 6 | template<typename T> |
| 7 | void f0(T x, __typeof__(f(x)) y) { } // expected-note{{previous}} |
Douglas Gregor | b197572 | 2009-07-30 23:18:24 +0000 | [diff] [blame] | 8 | |
Douglas Gregor | 4a3f780 | 2009-07-31 15:45:02 +0000 | [diff] [blame] | 9 | template<typename T> |
| 10 | void f0(T x, __typeof__((f)(x)) y) { } |
Douglas Gregor | b197572 | 2009-07-30 23:18:24 +0000 | [diff] [blame] | 11 | |
Douglas Gregor | 4a3f780 | 2009-07-31 15:45:02 +0000 | [diff] [blame] | 12 | template<typename U> |
| 13 | void f0(U u, __typeof__(f(u))) { } // expected-error{{redefinition}} |
Douglas Gregor | 04d4bee | 2009-07-31 00:23:35 +0000 | [diff] [blame] | 14 | |
Douglas Gregor | 6ebd15e | 2009-07-31 05:24:01 +0000 | [diff] [blame] | 15 | // Test insane typeof(expr) overload set canonicalization |
| 16 | void f(int); |
| 17 | void f(double); |
| 18 | |
| 19 | template<typename T, T N> |
| 20 | void f0a(T x, __typeof__(f(N)) y) { } // expected-note{{previous}} |
| 21 | |
| 22 | void f(int); |
| 23 | |
| 24 | template<typename T, T N> |
Douglas Gregor | 6f2c46b | 2009-07-31 16:07:31 +0000 | [diff] [blame] | 25 | void f0a(T x, __typeof__(f(N)) y) { } // expected-error{{redefinition}} \ |
| 26 | // expected-note{{previous}} |
Douglas Gregor | 6ebd15e | 2009-07-31 05:24:01 +0000 | [diff] [blame] | 27 | |
| 28 | void f(float); |
| 29 | |
| 30 | template<typename T, T N> |
Douglas Gregor | 6f2c46b | 2009-07-31 16:07:31 +0000 | [diff] [blame] | 31 | void f0a(T x, __typeof__(f(N)) y) { } // expected-error{{redefinition}} |
Douglas Gregor | 6ebd15e | 2009-07-31 05:24:01 +0000 | [diff] [blame] | 32 | |
Douglas Gregor | 04d4bee | 2009-07-31 00:23:35 +0000 | [diff] [blame] | 33 | // Test dependently-sized array canonicalization |
| 34 | template<typename T, int N, int M> |
| 35 | void f1(T (&array)[N + M]) { } // expected-note{{previous}} |
| 36 | |
| 37 | template<typename T, int N, int M> |
| 38 | void f1(T (&array)[M + N]) { } |
| 39 | |
| 40 | template<typename T, int M, int N> |
| 41 | void f1(T (&array)[M + N]) { } // expected-error{{redefinition}} |
Douglas Gregor | 2ec09f1 | 2009-07-31 03:54:25 +0000 | [diff] [blame] | 42 | |
| 43 | // Test dependently-sized extended vector type canonicalization |
| 44 | template<typename T, int N, int M> |
| 45 | struct X2 { |
| 46 | typedef T __attribute__((ext_vector_type(N))) type1; |
| 47 | typedef T __attribute__((ext_vector_type(M))) type2; |
| 48 | typedef T __attribute__((ext_vector_type(N))) type3; |
| 49 | |
| 50 | void f0(type1); // expected-note{{previous}} |
| 51 | void f0(type2); |
| 52 | void f0(type3); // expected-error{{redeclared}} |
| 53 | }; |