Debian Codegraph @

gcc/testsuite/g++.dg/opt/reload3.C

raw
1 // PR target/38287
2 // { dg-do run }
3 // { dg-options "-O2 -mcpu=v8 -fPIC" { target { { sparc*-*-* } && { ilp32 && fpic } } } }
4 // { dg-skip-if "requires hosted libstdc++ for cstdlib abort" { ! hostedlib } }
5
6 #include <cstdlib>
7
8 typedef unsigned uint32_t __attribute__((mode (__SI__)));
9
10 class QTime
11 {
12 public:
13 explicit QTime(int ms = 0) : ds(ms) {}
14 static QTime currentTime() { return QTime(); }
15 QTime addMSecs(int ms) const;
16 int msecs() const { return ds; }
17 private:
18 unsigned ds;
19 };
20
21 static const uint32_t MSECS_PER_DAY = 86400000;
22
23 QTime QTime::addMSecs(int ms) const
24 {
25 QTime t;
26 if ( ms < 0 ) {
27 // % not well-defined for -ve, but / is.
28 int negdays = (MSECS_PER_DAY-ms) / MSECS_PER_DAY;
29 t.ds = ((int)ds + ms + negdays*MSECS_PER_DAY)
30 % MSECS_PER_DAY;
31 } else {
32 t.ds = ((int)ds + ms) % MSECS_PER_DAY;
33 }
34 return t;
35 }
36
37 int main()
38 {
39 if (QTime(1).addMSecs(1).msecs() != 2)
40 abort ();
41 return 0;
42 }