annotate gcc/testsuite/g++.old-deja/g++.other/overload11.C @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 // { dg-do assemble }
kono
parents:
diff changeset
2
kono
parents:
diff changeset
3 // Copyright (C) 1999 Free Software Foundation, Inc.
kono
parents:
diff changeset
4 // Contributed by Nathan Sidwell 5 Sep 1999 <nathan@acm.org>
kono
parents:
diff changeset
5
kono
parents:
diff changeset
6 // [over.match] 13.3 tells us where overload resolution occurs.
kono
parents:
diff changeset
7 // [over.match.call] 13.3.1.1 says that in
kono
parents:
diff changeset
8 // (...( postfix-expression )...) (expression-list)
kono
parents:
diff changeset
9 // the postfix-expression must be the name of a function (amongst some other
kono
parents:
diff changeset
10 // choices). This means comma and conditional exprs cannot be placed there.
kono
parents:
diff changeset
11 // This clause is the only one I can find which bans
kono
parents:
diff changeset
12 // (cond ? fna : fnb) (arglist)
kono
parents:
diff changeset
13 // which would be a major headache to have to implement.
kono
parents:
diff changeset
14 // [over.over] 13.4 tells us when the use of a function name w/o arguments is
kono
parents:
diff changeset
15 // resolved to the address of a particular function. These are determined by
kono
parents:
diff changeset
16 // the context of the function name, and it does allow more complicated primary
kono
parents:
diff changeset
17 // expressions.
kono
parents:
diff changeset
18
kono
parents:
diff changeset
19 // Using a naked function name is rather strange, we used to warn about it
kono
parents:
diff changeset
20 // (rather inconsistently), but subsequent changes broke the warning. Make
kono
parents:
diff changeset
21 // sure that doesn't happen again.
kono
parents:
diff changeset
22
kono
parents:
diff changeset
23
kono
parents:
diff changeset
24 void ovl (int); // { dg-message "ovl|candidate expects" } candidate
kono
parents:
diff changeset
25 void ovl (float); // { dg-message "ovl|candidate expects" } candidate
kono
parents:
diff changeset
26 void fn (int);
kono
parents:
diff changeset
27 void fna (int);
kono
parents:
diff changeset
28
kono
parents:
diff changeset
29 int main (int argc, char **argv)
kono
parents:
diff changeset
30 {
kono
parents:
diff changeset
31 void (*ptr) (int);
kono
parents:
diff changeset
32 void (*vptr) ();
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 (ovl) (1); // ok
kono
parents:
diff changeset
35 (&ovl) (1); // ok
kono
parents:
diff changeset
36 (ovl) (); // { dg-error "" } no matching candidates
kono
parents:
diff changeset
37 (&ovl) (); // { dg-error "" } not suitable for overload resolution
kono
parents:
diff changeset
38
kono
parents:
diff changeset
39 // 13.3.1.1 indicates that the following are errors -- the primary expression
kono
parents:
diff changeset
40 // is not the name of a function.
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 111
diff changeset
41 (0, ovl) (1); // { dg-error "7:no context" } not suitable for overload resolution
1830386684a0 gcc-9.2.0
anatofuz
parents: 111
diff changeset
42 (0, &ovl) (1); // { dg-error "7:no context" } not suitable for overload resolution
111
kono
parents:
diff changeset
43 (argc ? ovl : ovl) (1); // { dg-error "" } not suitable for overload resolution
kono
parents:
diff changeset
44 (argc ? &ovl : &ovl) (1); // { dg-error "" } not suitable for overload resolution
kono
parents:
diff changeset
45
kono
parents:
diff changeset
46 (fn) (1); // ok
kono
parents:
diff changeset
47 (&fn) (1); // ok (no overload resolution)
kono
parents:
diff changeset
48 (0, fn) (1); // ok (no overload resolution)
kono
parents:
diff changeset
49 (0, &fn) (1); // ok (no overload resolution)
kono
parents:
diff changeset
50 (argc ? fna : fn) (1); // ok (no overload resolution)
kono
parents:
diff changeset
51 (argc ? &fna : &fn) (1); // ok (no overload resolution)
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 ptr = (ovl); // ok
kono
parents:
diff changeset
54 ptr = (&ovl); // ok
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 111
diff changeset
55 ptr = (0, ovl); // ok { dg-error "13:no context" }
1830386684a0 gcc-9.2.0
anatofuz
parents: 111
diff changeset
56 ptr = (0, &ovl); // ok { dg-error "13:no context" }
111
kono
parents:
diff changeset
57 ptr = (argc ? ovl : ovl); // ok { dg-error "no context" }
kono
parents:
diff changeset
58 ptr = (argc ? &ovl : &ovl);// ok { dg-error "no context" }
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 vptr = (ovl); // { dg-error "" } no matching candidates
kono
parents:
diff changeset
61 vptr = (&ovl); // { dg-error "" } no matching candidates
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 111
diff changeset
62 vptr = (0, ovl); // { dg-error "14:no context" } no matching candidates
1830386684a0 gcc-9.2.0
anatofuz
parents: 111
diff changeset
63 vptr = (0, &ovl); // { dg-error "14:no context" } no matching candidates
111
kono
parents:
diff changeset
64 vptr = (argc ? ovl : ovl); // { dg-error "" } no matching candidates
kono
parents:
diff changeset
65 vptr = (argc ? &ovl : &ovl);// { dg-error "" } no matching candidates
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 ptr = (fn);
kono
parents:
diff changeset
68 ptr = (&fn);
kono
parents:
diff changeset
69 ptr = (0, fn);
kono
parents:
diff changeset
70 ptr = (0, &fn);
kono
parents:
diff changeset
71 ptr = (argc ? fna : fn);
kono
parents:
diff changeset
72 ptr = (argc ? &fna : &fn);
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 f; // { dg-error "" } not a call
kono
parents:
diff changeset
75 ovl; // { dg-error "" } not suitable for overload
kono
parents:
diff changeset
76 &ovl; // { dg-error "" } not suitable for overload
kono
parents:
diff changeset
77 (void)f; // ok
kono
parents:
diff changeset
78 (void)ovl; // { dg-error "" } not suitable for overload
kono
parents:
diff changeset
79 (void)&ovl; // { dg-error "" } not suitable for overload
kono
parents:
diff changeset
80 static_cast<void>(f); // ok
kono
parents:
diff changeset
81 static_cast<void>(ovl); // { dg-error "" } not suitable for overload
kono
parents:
diff changeset
82 static_cast<void>(&ovl); // { dg-error "" } not suitable for overload
kono
parents:
diff changeset
83 ((void)1, f); // { dg-warning "" "" { xfail *-*-* } } not a call
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 111
diff changeset
84 ((void)1, ovl); // { dg-error "13:no context" } not suitable for overload
1830386684a0 gcc-9.2.0
anatofuz
parents: 111
diff changeset
85 ((void)1, &ovl); // { dg-error "13:no context" } not suitable for overload
111
kono
parents:
diff changeset
86 (void)((void)1, f); // ok
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 111
diff changeset
87 (void)((void)1, ovl); // { dg-error "19:no context" } not suitable for overload
1830386684a0 gcc-9.2.0
anatofuz
parents: 111
diff changeset
88 (void)((void)1, &ovl); // { dg-error "19:no context" } not suitable for overload
111
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 return 0;
kono
parents:
diff changeset
91 }