OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.old-deja/] [g++.benjamin/] [tem03.C] - Blame information for rev 699

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 699 jeremybenn
// { dg-do assemble  }
2
// 980808-980824 bkoz
3
// template parameter redeclaration bugs
4
 
5
// 14.1 Template parameters
6
// p 13
7
// The scope of a template-parameter extens from its point of
8
// declartion until the end of its template. In particular, a
9
// template-parameter can be used in the declaration of subsequent
10
// template-parameters and their default arguments.
11
 
12
// 14.6.1 Locally declared names
13
// p 4
14
// A template-parameter shall not be redeclared within its scope
15
// (including nested scopes). A template-parameter shall not have the
16
// sname name as the template name.
17
 
18
 
19
// 01
20
// declared friend template
21
template // { dg-error "" } .*
22
class Xone {
23
protected:
24
  T4* next;
25
  T4* prev;
26
  T4 value;
27
public:
28
  Xone(): next(0), prev(0), value(1999){}
29
  Xone(T4 init): value(init) {}
30
 
31
  // these are ok:
32
  // can also do template-decl and then can ditch the foward-declaration
33
  // template  friend bool isequal (Xone& lhs, Xone& rhs);
34
  // this is not ok:
35
  template  friend bool isequal (Xone& lhs, Xone& rhs);// { dg-error "" } .*
36
};
37
 
38
 
39
// 02
40
// nested template class
41
template // { dg-error "" } .*
42
class Xtwo {
43
protected:
44
  T6* next;
45
  T6* prev;
46
  T6 value;
47
public:
48
  Xtwo(): next(0), prev(0), value(1999){}
49
  Xtwo(T6 init): value(init) {}
50
 
51
  template  class nested {// { dg-error "" } .*
52
    T6 value;
53
  public:
54
    nested(): value( T6(0)) {}
55
  };
56
};
57
 
58
 
59
// 03
60
// member templates
61
template // { dg-error "" } .*
62
class Xthree {
63
protected:
64
  T8* next;
65
  T8* prev;
66
  T8 value;
67
public:
68
  Xthree(): next(0), prev(0), value(1999){}
69
  Xthree(T8 init): value(init) {}
70
 
71
  template  T8 comp_ge(T8 test) {// { dg-error "" } .*
72
    T8 local_value;
73
    if (local_value > value)
74
      return local_value;
75
    else
76
      return value;
77
  }
78
};
79
 
80
 
81
// 04
82
// local names (14.6.1 p 4)
83
template  struct Xfour {// { dg-error "" } .*
84
  int T10; // { dg-error "" } .*
85
  void f(){
86
    char T10; // { dg-error "declaration of 'char T10'" }
87
  }
88
};
89
 
90
 
91
// 05
92
// using different tempate-parms for out-of-line defs
93
template  struct Xfive {
94
  void f();
95
};
96
 
97
template  void Xfive::f() {// { dg-error "" } .*
98
  int T13; // { dg-error "" } .*
99
  int T12; //should be ok
100
}
101
 
102
 
103
// 06
104
// multiple names at the same level
105
template  class Xsix { // { dg-error "" } .*
106
private:
107
public:
108
  void f();
109
};
110
 
111
 
112
// 07
113
// multiple names, one in template parameter one in class-name
114
template  class T12; // { dg-error "" } .*
115
 
116
 
117
// 08
118
// with multiple template params, and second (third) one is redeclared
119
template  class Xseven { // { dg-error "" } .*
120
private:
121
  char T161; // { dg-error "" } .*
122
public:
123
  template 
124
  friend bool fooy(U u);
125
 
126
  template  // { dg-error "declaration of 'class T161'" }
127
  friend bool foo(T161 u)
128
    {
129
      Xseven obj;
130
      return (obj.inst == u.inst);
131
    }
132
 
133
};
134
 
135
 
136
// 09
137
// check for correct scoping of member templates
138
template 
139
struct S1
140
{
141
  template 
142
  void f(U u)
143
    {
144
      S1 s2u(u);
145
      s2u.g();
146
    }
147
 
148
  template  //ok
149
  void f2(U u)
150
    {
151
      S1 s2u(u);
152
      s2u.g();
153
    }
154
 
155
};
156
 
157
 
158
// 10
159
// check for non-type parameters, should still be able to redeclare?
160
// local names (14.6.1 p 4)
161
template  class Xten {// { dg-error "" } .*
162
  float i; // { dg-error "" } .*
163
};
164
 
165
 
166
// 11
167
// declared friend template, non-type parameters
168
template // { dg-error "" } .*
169
class Xeleven {
170
public:
171
  template  friend bool isequal (Xeleven<5> lhs, Xeleven<5> rhs);  // { dg-error "" } .*
172
};
173
 
174
 
175
 
176
// 12
177
// nested template class, non-type parameters
178
template // { dg-error "" } .*
179
class Xtwelve {
180
public:
181
  template  class nested {// { dg-error "" } .
182
    long value;
183
  public:
184
    nested(): value(0) {}
185
  };
186
};
187
 
188
 
189
// 13
190
// member templates, non-type parameters
191
template // { dg-error "" } .*
192
struct Xthirteen {
193
  template  long comp_ge(long test) {// { dg-error "" } .
194
    long local_value;
195
    if (local_value > value) // { dg-error "" } .*
196
      return local_value;
197
    else
198
      return value;
199
  }
200
};
201
 
202
 
203
 
204
 
205
 
206
 
207
 
208
 
209
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.