summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/warn/noeffect4.C
blob: 966716bbc48c36f52f11494bbbaa3e63e1bd60cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// { dg-do compile }
// { dg-options "-Wall" }

// Copyright (C) 2003 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 2 Sep 2003 <nathan@codesourcery.com>

// PR 12037.

struct X
{
  int operator+(int);
  int operator-(int);
  int operator*(int);
  int operator/(int);
  int operator%(int);
  int operator>>(int);
  int operator<<(int);
  int operator&(int);
  int operator|(int);
  int operator^(int);
  int operator&&(int);
  int operator||(int);
  int operator==(int);
  int operator!=(int);
  int operator<(int);
  int operator<=(int);
  int operator>(int);
  int operator>=(int);
  int operator*();
  int operator!();
  int operator~();
  int operator++();
  int operator--();
  int operator++(int);
  int operator--(int);
  int operator()();
  int operator,(int);
  X *operator->();
  operator int () const;
  int m;
  virtual ~X ();
  X &Foo ();
};
struct Y : X 
{
};

template<int I> void Foo (X &x)
{
  x + I;
  x - I;
  x * I;
  x / I;
  x % I;
  x >> I;
  x << I;
  x & I;
  x | I;
  x && I;
  x || I;
  x == I;
  x != I;
  x < I;
  x <= I;
  x > I;
  x >= I;
  *x;
  !x;
  ~x;
  x++;
  x--;
  ++x;
  --x;
  x ();
  x, I;
  x->m;
  static_cast<int> (x);
  dynamic_cast<Y &> (x);
  reinterpret_cast<int> (x.Foo ()); // { dg-error "invalid cast" }
  const_cast<X &> (x.Foo ());       // { dg-warning "not used" }
  
  reinterpret_cast<int *> (&x);// { dg-warning "no effect" "" }
  const_cast<X &> (x);         // { dg-warning "no effect" "" }
  sizeof (x++);                // { dg-warning "no effect" "" }
  __alignof__ (x++);           // { dg-warning "no effect" "" }
}

template void Foo<4> (X&);     // { dg-message "instantiated" }