Merge from mainline (gomp-merge-2005-02-26).
[official-gcc.git] / gcc / testsuite / g++.dg / template / error10.C
blobdcb4f3e08fe0c40820c2780d99c6aa92e5b1c7c0
1 // { dg-do compile }
2 // Origin: <tilps at hotmail dot com>
3 // c++/9154: poor error message for ">>" vs "> >" in template argument list
6 /*
7  * Test that the error message is issued properly
8  */
9 template <class T>
10 class A {};
12 A<A<int>> blah;  // { dg-error "should be '> >' within" }
13 A<int>> blah2; // { dg-error "spurious '>>'" }
17  * Test that a few valid constructs containing a ">>" token in a
18  * template argument list are handled correctly.
19  */
20 template <int N>
21 void B(void) {}
23 int Btest()
25   B<256 >> 4>();
28 template <int N = 123>>4>
29 struct C {};
31 template <int>      struct D {};
32 template <typename> struct E {};
34 E<D< 1>>2 > > E1;
36 const int x = 0;
37 E<D< 1>>x > > E2;
39 template <int> struct F {
40   typedef int I;
43 template <typename T = F< 1>>2 >::I>
44 struct G {};
47  * In this special case, a valid type-id (H() is a function type) is followed
48  * by '>>', but the argument should still be parsed as an expression, which
49  * will then be rejected as non-constant expression.
50  */
51 struct H
53   int operator >>(int);
56 template <int V> struct L {};
57 L<H() >> 5> l;  // { dg-error "" "non-constant" }
61  * This case used to not emit the nice error message because of a typo
62  *  in the code.
63  */
64 template <void (*)(void)>
65 struct K {};
67 void KFunc(void);
69 A<K<&KFunc>> k1;  // { dg-error "" }
70 K<&KFunc>> k2; // { dg-error "" }