blob: 0580c677e62781fd607386cab22f945a9a6d3a49 [file] [log] [blame]
Douglas Gregorb1975722009-07-30 23:18:24 +00001// RUN: clang-cc -fsyntax-only -verify %s
2
3void f();
4
Douglas Gregorb1975722009-07-30 23:18:24 +00005// Test typeof(expr) canonicalization
Douglas Gregor4a3f7802009-07-31 15:45:02 +00006template<typename T>
7void f0(T x, __typeof__(f(x)) y) { } // expected-note{{previous}}
Douglas Gregorb1975722009-07-30 23:18:24 +00008
Douglas Gregor4a3f7802009-07-31 15:45:02 +00009template<typename T>
10void f0(T x, __typeof__((f)(x)) y) { }
Douglas Gregorb1975722009-07-30 23:18:24 +000011
Douglas Gregor4a3f7802009-07-31 15:45:02 +000012template<typename U>
13void f0(U u, __typeof__(f(u))) { } // expected-error{{redefinition}}
Douglas Gregor04d4bee2009-07-31 00:23:35 +000014
Douglas Gregor6ebd15e2009-07-31 05:24:01 +000015// Test insane typeof(expr) overload set canonicalization
16void f(int);
17void f(double);
18
19template<typename T, T N>
20void f0a(T x, __typeof__(f(N)) y) { } // expected-note{{previous}}
21
22void f(int);
23
24template<typename T, T N>
Douglas Gregor6f2c46b2009-07-31 16:07:31 +000025void f0a(T x, __typeof__(f(N)) y) { } // expected-error{{redefinition}} \
26 // expected-note{{previous}}
Douglas Gregor6ebd15e2009-07-31 05:24:01 +000027
28void f(float);
29
30template<typename T, T N>
Douglas Gregor6f2c46b2009-07-31 16:07:31 +000031void f0a(T x, __typeof__(f(N)) y) { } // expected-error{{redefinition}}
Douglas Gregor6ebd15e2009-07-31 05:24:01 +000032
Douglas Gregor04d4bee2009-07-31 00:23:35 +000033// Test dependently-sized array canonicalization
34template<typename T, int N, int M>
35void f1(T (&array)[N + M]) { } // expected-note{{previous}}
36
37template<typename T, int N, int M>
38void f1(T (&array)[M + N]) { }
39
40template<typename T, int M, int N>
41void f1(T (&array)[M + N]) { } // expected-error{{redefinition}}
Douglas Gregor2ec09f12009-07-31 03:54:25 +000042
43// Test dependently-sized extended vector type canonicalization
44template<typename T, int N, int M>
45struct 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};