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