Debian Codegraph @

gcc/testsuite/g++.dg/Wattributes-3.C

raw
1 // PR c++/83394 - always_inline vs. noinline no longer diagnosed
2 // { dg-do compile }
3 // { dg-options "-Wattributes" }
4
5 #define ATTR(list) __attribute__ (list)
6
7 struct A
8 {
9 ATTR ((__noinline__)) operator int ();
10 };
11
12 ATTR ((__always_inline__))
13 A::operator int () // { dg-warning "ignoring attribute .always_inline. because it conflicts with attribute .noinline." }
14 {
15 return 0;
16 }
17
18
19 struct B
20 {
21 operator char () const;
22 ATTR ((__always_inline__)) operator int () const;
23 };
24
25 B::operator char () const { return 0; }
26
27 ATTR ((__noinline__))
28 B::operator int () const // { dg-warning "ignoring attribute .noinline. because it conflicts with attribute .always_inline." }
29 // { dg-warning "function might not be inlinable unless also declared .inline." "" { target *-*-* } .-1 }
30
31 {
32 return 0;
33 }
34
35
36 struct C
37 {
38 operator char ();
39 ATTR ((__always_inline__)) operator short ();
40 operator int ();
41 ATTR ((__noinline__)) operator long ();
42 };
43
44 C::operator char () { return 0; }
45
46 ATTR ((__noinline__))
47 C::operator short () // { dg-warning "ignoring attribute .noinline. because it conflicts with attribute .always_inline." }
48 // { dg-warning "function might not be inlinable unless also declared .inline." "" { target *-*-* } .-1 }
49 { return 0; }
50
51 inline ATTR ((__noinline__))
52 C::operator int ()
53 { return 0; }
54
55
56 ATTR ((__always_inline__))
57 C::operator long () // { dg-warning "ignoring attribute .always_inline. because it conflicts with attribute .noinline." }
58 { return 0; }
59
60
61 struct D
62 {
63 int foo ();
64 int foo (int);
65 int ATTR ((const)) foo (int, int);
66 int ATTR ((pure)) foo (int, int, int);
67
68 int ATTR ((const)) foo (int, int, int, int);
69
70 int foo (int, int, int, int, int);
71 };
72
73 int ATTR ((const))
74 D::foo ()
75 { return 0; }
76
77 int ATTR ((pure))
78 D::foo (int)
79 { return 0; }
80
81 int ATTR ((pure))
82 D::foo (int, int) // { dg-warning "ignoring attribute .pure. because it conflicts with attribute .const." }
83 { return 0; }
84
85 int ATTR ((const))
86 D::foo (int, int, int) // { dg-warning "ignoring attribute .const. because it conflicts with attribute .pure." }
87 { return 0; }
88
89 int
90 D::foo (int, int, int, int) { return 0; }
91
92 int ATTR ((const))
93 D::foo (int, int, int, int, int) { return 0; }