remove a dead bool.
[llvm/avr.git] / test / FrontendC++ / 2008-10-29-WrongOffset.cpp
blob1b3be2132b185bdcf7c5a4ae0de9381e6103bb26
1 // RUN: %llvmgxx %s -c -o /dev/null
2 // PR2917
4 #include <complex>
5 template < int Dim, class T, class EngineTag > class Engine;
6 template < class Subject, class Sub1, bool SV > struct View1Implementation;
7 template < class LayoutTag, class PatchTag > struct MultiPatch;
8 template < class LayoutTag, class PatchTag, int Dim2 > struct MultiPatchView;
9 template < class Engine, class SubDomain > struct NewEngine
12 template < class T > class DomainTraits;
13 template < class DomT, class T, int Dim > struct DomainTraitsDomain
15 typedef DomT NewDomain1_t;
17 template < int Dim > class Interval;
18 template < int Dim > class Loc;
19 template < class DT > class DomainBase
23 template < int Dim, class DT > class Domain:public DomainBase < DT >
26 template < int Dim > struct DomainTraits <Interval < Dim >
27 >:public DomainTraitsDomain < Interval < Dim >, int, Dim >
29 enum
31 singleValued = false
34 template < class T1 > struct NewDomain1
36 typedef typename DomainTraits < T1 >::NewDomain1_t SliceType_t;
38 template < class Domain, class Sub > struct TemporaryNewDomain1
40 typedef typename NewDomain1 < Sub >::SliceType_t SliceType_t;
42 template < int Dim > class Interval:public Domain < Dim,
43 DomainTraits < Interval < Dim > > >
46 template < int Dim > class GuardLayers
49 template < class T > class Observer
53 template < class T > class Observable
55 private:T & observed_m;
56 int count_m;
59 class RefCounted
62 template < class T > class RefCountedPtr
64 public:typedef RefCountedPtr < T > This_t;
65 RefCountedPtr (T * const pT):ptr_m (pT)
68 inline T *operator-> () const
71 T *ptr_m;
74 template < class Dom, class T > class DomainMap
78 template < class LayoutTag, int Dim > struct MultiPatchLayoutTraits
81 template < int Dim > class LayoutBaseData
83 public:typedef Interval < Dim > Domain_t;
84 Domain_t domain_m;
86 template < int Dim, class LBD > class LayoutBase
88 public:typedef LayoutBaseData < Dim > LayoutData_t;
89 typedef typename LayoutData_t::Domain_t Domain_t;
90 typedef GuardLayers < Dim > GuardLayers_t;
91 inline const Domain_t & domain () const
93 return pdata_m->domain_m;
95 inline const Domain_t & innerDomain () const
98 inline GuardLayers_t externalGuards () const
101 RefCountedPtr < LBD > pdata_m;
103 template < class Tag > struct Remote;
104 struct Brick
107 template < class Thing, class Sub > struct View1
110 template < int Dim, class T, class LayoutTag,
111 class PatchTag > struct NewEngine <Engine < Dim, T, MultiPatch < LayoutTag,
112 PatchTag > >, Interval < Dim > >
114 typedef Engine < Dim, T, MultiPatchView < LayoutTag, PatchTag,
115 Dim > >Type_t;
117 template < int Dim, class T, class LayoutTag, class PatchTag,
118 int Dim2 > struct NewEngine <Engine < Dim, T, MultiPatchView < LayoutTag,
119 PatchTag, Dim2 > >, Interval < Dim > >
121 typedef Engine < Dim, T, MultiPatchView < LayoutTag, PatchTag,
122 Dim2 > >Type_t;
124 template < int Dim, class T, class LayoutTag,
125 class PatchTag > class Engine < Dim, T, MultiPatch < LayoutTag,
126 PatchTag > >:public Observer < typename MultiPatchLayoutTraits < LayoutTag,
127 Dim >::Layout_t >
129 public:typedef MultiPatch < LayoutTag, PatchTag > Tag_t;
130 typedef Interval < Dim > Domain_t;
132 template < int Dim, class T, class LayoutTag, class PatchTag,
133 int Dim2 > class Engine < Dim, T, MultiPatchView < LayoutTag, PatchTag,
134 Dim2 > >
136 public:typedef MultiPatchView < LayoutTag, PatchTag, Dim2 > Tag_t;
137 typedef Interval < Dim > Domain_t;
138 typedef T Element_t;
139 enum
141 dimensions = Dim
144 class Full;
145 template < int Dim, class T = double, class EngineTag = Full > class Vector {
148 template < int Dim > inline Interval < Dim >
149 shrinkRight (const Interval < Dim > &dom, int s)
153 template < int Dim > class GridLayout;
154 struct GridTag
157 template < int Dim > struct MultiPatchLayoutTraits <GridTag, Dim >
159 typedef GridLayout < Dim > Layout_t;
161 template < int Dim > class GridLayoutData:public LayoutBaseData < Dim >,
162 public RefCounted, public Observable < GridLayoutData < Dim > >
164 typedef int AxisIndex_t;
165 mutable DomainMap < Interval < 1 >, AxisIndex_t > mapAloc_m[Dim];
167 template < int Dim > class GridLayout:public LayoutBase < Dim,
168 GridLayoutData < Dim > >, public Observable < GridLayout < Dim > >,
169 public Observer < GridLayoutData < Dim > >
171 public:typedef GridLayout < Dim > This_t;
172 GridLayout ();
174 template < class MeshTag, class T, class EngineTag > class Field;
175 enum CenteringType
177 VertexType, EdgeType, FaceType, CellType
179 enum ContinuityType
181 Continuous = 0, Discontinuous
183 template < int Dim > class Centering
185 public:typedef Loc < Dim > Orientation;
186 inline int size () const
190 template < int Dim > const Centering < Dim >
191 canonicalCentering (const enum CenteringType type,
192 const enum ContinuityType discontinuous,
193 const int dimension = 0);
194 template < class Mesh, class T, class EngineTag > class FieldEngine
196 public:enum
198 dimensions = Mesh::dimensions
200 enum
202 Dim = dimensions
204 typedef Engine < Dim, T, EngineTag > Engine_t;
205 typedef typename Engine_t::Domain_t Domain_t;
206 typedef GuardLayers < Dim > GuardLayers_t;
207 template < class Layout2 > FieldEngine (const Centering < Dim > &centering, const Layout2 & layout, const Mesh & mesh, int materials = 1):num_materials_m (materials), centering_m (centering),
208 stride_m (centering.size ()), physicalCellDomain_m (layout.domain ()),
209 guards_m (layout.externalGuards ()), mesh_m (mesh)
212 unsigned int num_materials_m;
213 Centering < Dim > centering_m;
214 int stride_m;
215 Domain_t physicalCellDomain_m;
216 GuardLayers_t guards_m;
217 Mesh mesh_m;
220 template < class Subject > class SubFieldView;
221 template < class Mesh, class T,
222 class EngineTag > class SubFieldView < Field < Mesh, T, EngineTag > >
224 public:typedef Field < Mesh, T, EngineTag > Type_t;
227 template < int Dim, class Mesh, class Domain > struct NewMeshTag
229 typedef Mesh Type_t;
231 template < class Mesh, class T, class EngineTag,
232 class Domain > struct View1Implementation <Field < Mesh, T, EngineTag >,
233 Domain, false >
235 typedef Field < Mesh, T, EngineTag > Subject_t;
236 typedef typename Subject_t::Engine_t Engine_t;
237 typedef typename NewEngine < Engine_t, Domain >::Type_t NewEngine_t;
238 typedef typename NewEngine_t::Element_t NewT_t;
239 typedef typename NewEngine_t::Tag_t NewEngineTag_t;
240 typedef typename NewMeshTag < NewEngine_t::dimensions, Mesh,
241 Domain >::Type_t NewMeshTag_t;
242 typedef Field < NewMeshTag_t, NewT_t, NewEngineTag_t > Type_t;
244 template < class Mesh, class T, class EngineTag,
245 class Sub1 > struct View1 <Field < Mesh, T, EngineTag >, Sub1 >
247 typedef Field < Mesh, T, EngineTag > Subject_t;
248 typedef typename Subject_t::Domain_t Domain_t;
249 typedef TemporaryNewDomain1 < Domain_t, Sub1 > NewDomain_t;
250 typedef typename NewDomain_t::SliceType_t SDomain_t;
251 enum
253 sv = DomainTraits < SDomain_t >::singleValued
255 typedef View1Implementation < Subject_t, SDomain_t, sv > Dispatch_t;
256 typedef typename Dispatch_t::Type_t Type_t;
258 template < class Mesh, class T = double, class EngineTag = Brick > class Field {
259 public:typedef Mesh MeshTag_t;
260 typedef Mesh Mesh_t;
261 typedef Field < Mesh, T, EngineTag > This_t;
262 typedef FieldEngine < Mesh, T, EngineTag > FieldEngine_t;
263 enum
265 dimensions = FieldEngine_t::dimensions
267 typedef Engine < dimensions, T, EngineTag > Engine_t;
268 typedef typename Engine_t::Domain_t Domain_t;
269 typedef Centering < dimensions > Centering_t;
270 template < class Layout2 > Field (const Centering_t & centering,
271 const Layout2 & layout,
272 const Mesh_t &
273 mesh):fieldEngine_m (centering, layout,
274 mesh)
277 inline typename SubFieldView < This_t >::Type_t center (int c) const
280 inline typename View1 < This_t, Domain_t >::Type_t all () const
283 template < class T1 > const This_t & operator= (const T1 & rhs) const
286 private: FieldEngine_t fieldEngine_m;
289 struct UniformRectilinearTag
292 struct CartesianTag
295 template < class MeshTraits > struct CartesianURM;
296 template < class MeshTraits > class UniformRectilinearMeshData;
297 template < class MeshTraits > class UniformRectilinearMesh;
298 template < int Dim, typename T = double, class MeshTag =
299 UniformRectilinearTag, class CoordinateSystemTag = CartesianTag, int CDim =
300 Dim > struct MeshTraits;
301 template < int Dim, typename T, class MeshTag, class CoordinateSystemTag,
302 int CDim > struct MeshTraitsBase
304 typedef MeshTraits < Dim, T, MeshTag, CoordinateSystemTag,
305 CDim > MeshTraits_t;
306 enum
308 dimensions = Dim
310 typedef Vector < CDim, T > PointType_t;
312 template < int Dim, typename T, int CDim > struct MeshTraits <Dim, T,
313 UniformRectilinearTag, CartesianTag, CDim >:public MeshTraitsBase < Dim, T,
314 UniformRectilinearTag, CartesianTag, CDim >
316 typedef typename MeshTraitsBase < Dim, T, UniformRectilinearTag,
317 CartesianTag, CDim >::MeshTraits_t MeshTraits_t;
318 typedef CartesianURM < MeshTraits_t > CoordinateSystem_t;
319 typedef UniformRectilinearMeshData < MeshTraits_t > MeshData_t;
320 typedef UniformRectilinearMesh < MeshTraits_t > Mesh_t;
321 typedef Vector < CDim, T > SpacingsType_t;
323 template < int Dim > class NoMeshData:public RefCounted
325 public:NoMeshData ()
328 template < class Layout >
329 explicit NoMeshData (const Layout &
330 layout):physicalVertexDomain_m (layout.
331 innerDomain ()),
332 physicalCellDomain_m (shrinkRight (physicalVertexDomain_m, 1)),
333 totalVertexDomain_m (layout.domain ()),
334 totalCellDomain_m (shrinkRight (totalVertexDomain_m, 1))
337 private:Interval < Dim > physicalVertexDomain_m, physicalCellDomain_m;
338 Interval < Dim > totalVertexDomain_m, totalCellDomain_m;
341 template < class MeshTraits > class UniformRectilinearMeshData:public NoMeshData <
342 MeshTraits::
343 dimensions >
345 public:typedef typename
346 MeshTraits::MeshData_t
347 MeshData_t;
348 typedef typename
349 MeshTraits::PointType_t
350 PointType_t;
351 typedef typename
352 MeshTraits::SpacingsType_t
353 SpacingsType_t;
354 enum
356 dimensions = MeshTraits::dimensions
358 template < class Layout > UniformRectilinearMeshData (const Layout & layout,
359 const PointType_t &
360 origin,
361 const SpacingsType_t &
362 spacings):
363 NoMeshData <
364 dimensions > (layout),
365 origin_m (origin),
366 spacings_m (spacings)
369 private:PointType_t origin_m;
370 SpacingsType_t
371 spacings_m;
374 template < class MeshTraits > class UniformRectilinearMesh:public MeshTraits::
375 CoordinateSystem_t
377 public:typedef MeshTraits
378 MeshTraits_t;
379 typedef typename
380 MeshTraits::MeshData_t
381 MeshData_t;
382 typedef typename
383 MeshTraits::PointType_t
384 PointType_t;
385 typedef typename
386 MeshTraits::SpacingsType_t
387 SpacingsType_t;
388 enum
390 dimensions = MeshTraits::dimensions
392 template < class Layout >
393 inline UniformRectilinearMesh (const Layout & layout,
394 const PointType_t & origin,
395 const SpacingsType_t & spacings):
396 data_m (new MeshData_t (layout, origin, spacings))
399 private:RefCountedPtr < MeshData_t > data_m;
402 template < class MeshTraits > struct GenericURM
405 template < class MeshTraits > struct CartesianURM:
406 public
407 GenericURM <
408 MeshTraits >
411 template < int
412 dim,
413 class
414 MeshTag = UniformRectilinearTag, class CoordinateSystemTag = CartesianTag > struct ParallelTraits {
415 enum
417 Dim = dim
419 typedef
420 GridLayout <
421 dim >
422 Layout_t;
423 typedef
424 MeshTraits <
425 dim, double,
426 MeshTag,
427 CoordinateSystemTag >
428 MeshTraits_t;
429 typedef typename
430 MeshTraits_t::Mesh_t
431 Mesh_t;
432 typedef
433 MultiPatch <
434 GridTag,
435 Remote <
436 Brick > >
437 Engine_t;
439 template < class ComputeTraits > struct RhalkTraits:
440 public
441 ComputeTraits
443 typedef typename
444 ComputeTraits::Mesh_t
445 Mesh_t;
446 typedef typename
447 ComputeTraits::Engine_t
448 Engine_t;
449 enum
451 Dim = ComputeTraits::Dim
453 typedef
454 Centering <
455 Dim >
456 Centering_t;
457 typedef typename
458 Mesh_t::SpacingsType_t
459 Spacings_t;
460 typedef
461 Field <
462 Mesh_t, double,
463 Engine_t >
464 Scalar_t;
466 enum
468 Dim = 3
470 typedef
471 RhalkTraits <
472 ParallelTraits <
473 Dim,
474 UniformRectilinearTag,
475 CartesianTag > >
476 Traits_t;
477 Vector < Dim > origin;
478 Traits_t::Spacings_t spacings;
480 main (int argc, char **argv)
482 Traits_t::Layout_t layout;
483 Traits_t::Mesh_t mesh (layout, origin, spacings);
484 Traits_t::Centering_t face =
485 canonicalCentering < Traits_t::Dim > (FaceType, Continuous);
486 Traits_t::Scalar_t v (face, layout, mesh);
487 for (int i = 0; i < Dim; ++i)
488 v.center (i).all () = std::numeric_limits < double >::signaling_NaN ();