3 // Copyright (C) 1999 Free Software Foundation, Inc.
4 // Contributed by Nathan Sidwell 5 Sep 1999 <nathan@acm.org>
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
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.
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 }
31 int main (int argc, char **argv)
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
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
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)
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" }
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
73 ptr = (argc ? fna : fn);
74 ptr = (argc ? &fna : &fn);
76 f; // { dg-error "" } not a call
77 ovl; // { dg-error "" } not suitable for overload
78 &ovl; // { dg-error "" } not suitable for overload
80 (void)ovl; // { dg-error "" } not suitable for overload
81 (void)&ovl; // { dg-error "" } not suitable for overload
82 static_cast<void>(f); // ok
83 static_cast<void>(ovl); // { dg-error "" } not suitable for overload
84 static_cast<void>(&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