Irradiation of moving targets using a scanned ion beam can cause clinically intolerable under- and overdosages within the target volume due to the interplay effect. Several motion mitigation techniques such as gating, beam tracking and rescanning are currently investigated to overcome this restriction. To enable detailed experimental studies of potential mitigation techniques a complex thorax phantom was developed. The phantom consists of an artificial thorax with ribs to introduce density changes. The contraction of the thorax can be controlled by a stepping motor. A robotic driven detector head positioned inside the thorax mimics e.g. a lung tumour. The detector head comprises 20 ionization chambers and 5 radiographic films for target dose measurements. The phantom's breathing as well as the 6D tumour motion (3D translation, 3D rotation) can be programmed independently and adjusted online. This flexibility allows studying the dosimetric effects of correlation mismatches between internal and external motions, irregular breathing, or baseline drifts to name a few. Commercial motion detection systems, e.g. VisionRT or Anzai belt, can be mounted as they would be mounted in a patient case. They are used to control the 4D treatment delivery and to generate data for 4D dose calculation. To evaluate the phantom's properties, measurements addressing reproducibility, stability, temporal behaviour and performance of dedicated breathing manoeuvres were performed. In addition, initial dosimetric tests for treatment with a scanned carbon beam are reported.