OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.old-deja/] [g++.other/] [overload11.C] - Blame information for rev 749

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 699 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-message "ovl|candidate expects" } candidate
25
void ovl (float);        // { dg-message "ovl|candidate expects" } 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
  // { dg-message "candidate" "candidate note" { target *-*-* } 36 }
38
  (&ovl) ();                // { dg-error "" } not suitable for overload resolution
39
 
40
  // 13.3.1.1 indicates that the following are errors -- the primary expression
41
  // is not the name of a function.
42
  (0, ovl) (1);             // { dg-error "" } not suitable for overload resolution
43
  (0, &ovl) (1);            // { dg-error "" } not suitable for overload resolution
44
  (argc ? ovl : ovl) (1);   // { dg-error "" } not suitable for overload resolution
45
  (argc ? &ovl : &ovl) (1); // { dg-error "" } not suitable for overload resolution
46
 
47
  (fn) (1);                 // ok
48
  (&fn) (1);                // ok (no overload resolution)
49
  (0, fn) (1);              // ok (no overload resolution)
50
  (0, &fn) (1);             // ok (no overload resolution)
51
  (argc ? fna : fn) (1);    // ok (no overload resolution)
52
  (argc ? &fna : &fn) (1);  // ok (no overload resolution)
53
 
54
  ptr = (ovl);              // ok
55
  ptr = (&ovl);             // ok
56
  ptr = (0, ovl);           // ok { dg-error "no context" }
57
  ptr = (0, &ovl);          // ok { dg-error "no context" }
58
  ptr = (argc ? ovl : ovl); // ok { dg-error "no context" }
59
  ptr = (argc ? &ovl : &ovl);// ok { dg-error "no context" }
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-error "" } 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
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.