1 |
12 |
jlechner |
// { 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 |
|
|
void ovl (float); // { dg-error "" } candidate
|
26 |
|
|
void fn (int);
|
27 |
|
|
void fna (int);
|
28 |
|
|
|
29 |
|
|
int main (int argc, char **argv)
|
30 |
|
|
{
|
31 |
|
|
void (*ptr) (int);
|
32 |
|
|
void (*vptr) ();
|
33 |
|
|
|
34 |
|
|
(ovl) (1); // ok
|
35 |
|
|
(&ovl) (1); // { dg-error "" } not suitable for overload resolution
|
36 |
|
|
(ovl) (); // { dg-error "" } no matching candidates
|
37 |
|
|
(&ovl) (); // { dg-error "" } not suitable for overload resolution
|
38 |
|
|
|
39 |
|
|
// 13.3.1.1 indicates that the following are errors -- the primary expression
|
40 |
|
|
// is not the name of a function.
|
41 |
|
|
(0, ovl) (1); // { dg-error "" } not suitable for overload resolution
|
42 |
|
|
(0, &ovl) (1); // { dg-error "" } not suitable for overload resolution
|
43 |
|
|
(argc ? ovl : ovl) (1); // { dg-error "" } not suitable for overload resolution
|
44 |
|
|
(argc ? &ovl : &ovl) (1); // { dg-error "" } not suitable for overload resolution
|
45 |
|
|
|
46 |
|
|
(fn) (1); // ok
|
47 |
|
|
(&fn) (1); // ok (no overload resolution)
|
48 |
|
|
(0, fn) (1); // ok (no overload resolution)
|
49 |
|
|
(0, &fn) (1); // ok (no overload resolution)
|
50 |
|
|
(argc ? fna : fn) (1); // ok (no overload resolution)
|
51 |
|
|
(argc ? &fna : &fn) (1); // ok (no overload resolution)
|
52 |
|
|
|
53 |
|
|
ptr = (ovl); // ok
|
54 |
|
|
ptr = (&ovl); // ok
|
55 |
|
|
// 13.4 indicates these are ok.
|
56 |
|
|
ptr = (0, ovl); // ok { dg-bogus "" "" { xfail *-*-* } }
|
57 |
|
|
ptr = (0, &ovl); // ok { dg-bogus "" "" { xfail *-*-* } }
|
58 |
|
|
ptr = (argc ? ovl : ovl); // ok { dg-bogus "" "" { xfail *-*-* } }
|
59 |
|
|
ptr = (argc ? &ovl : &ovl);// ok { dg-bogus "" "" { xfail *-*-* } }
|
60 |
|
|
|
61 |
|
|
vptr = (ovl); // { dg-error "" } no matching candidates
|
62 |
|
|
vptr = (&ovl); // { dg-error "" } no matching candidates
|
63 |
|
|
vptr = (0, ovl); // { dg-error "" } no matching candidates
|
64 |
|
|
vptr = (0, &ovl); // { dg-error "" } no matching candidates
|
65 |
|
|
vptr = (argc ? ovl : ovl); // { dg-error "" } no matching candidates
|
66 |
|
|
vptr = (argc ? &ovl : &ovl);// { dg-error "" } no matching candidates
|
67 |
|
|
|
68 |
|
|
ptr = (fn);
|
69 |
|
|
ptr = (&fn);
|
70 |
|
|
ptr = (0, fn);
|
71 |
|
|
ptr = (0, &fn);
|
72 |
|
|
ptr = (argc ? fna : fn);
|
73 |
|
|
ptr = (argc ? &fna : &fn);
|
74 |
|
|
|
75 |
|
|
f; // { dg-warning "" } not a call
|
76 |
|
|
ovl; // { dg-error "" } not suitable for overload
|
77 |
|
|
&ovl; // { dg-error "" } not suitable for overload
|
78 |
|
|
(void)f; // ok
|
79 |
|
|
(void)ovl; // { dg-error "" } not suitable for overload
|
80 |
|
|
(void)&ovl; // { dg-error "" } not suitable for overload
|
81 |
|
|
static_cast(f); // ok
|
82 |
|
|
static_cast(ovl); // { dg-error "" } not suitable for overload
|
83 |
|
|
static_cast(&ovl); // { dg-error "" } not suitable for overload
|
84 |
|
|
((void)1, f); // { dg-warning "" "" { xfail *-*-* } } not a call
|
85 |
|
|
((void)1, ovl); // { dg-error "" } not suitable for overload
|
86 |
|
|
((void)1, &ovl); // { dg-error "" } not suitable for overload
|
87 |
|
|
(void)((void)1, f); // ok
|
88 |
|
|
(void)((void)1, ovl); // { dg-error "" } not suitable for overload
|
89 |
|
|
(void)((void)1, &ovl); // { dg-error "" } not suitable for overload
|
90 |
|
|
|
91 |
|
|
return 0;
|
92 |
|
|
}
|