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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [g++.dg/] [overload/] [using2.C] - Blame information for rev 841

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

Line No. Rev Author Line
1 149 jeremybenn
// { dg-do compile }
2
 
3
// Copyright 2005 Free Software Foundation
4
// by Alexandre Oliva 
5
// based on https://bugzilla.redhat.com/beta/show_bug.cgi?id=149098
6
 
7
// Per the ISO C++ 90 Standard, using declarations before of after a
8
// declaration of the same function name and prototype should be
9
// errors (7.3.3/11).  However, DR 101's resolution recommends
10
// accepting such duplicates if they denote the same function, which
11
// means extern "C" declarations are supposed to match and be
12
// accepted.
13
 
14
// This test makes sure we reject or accept regular and using
15
// declarations regardless of order as appropriate, and that having
16
// built-in declarations or overloads doesn't affet the outcome.
17
 
18
namespace std {
19
  extern "C" void exit (int) throw (); // these are built-in (extern "C")
20
  extern "C" void *malloc (__SIZE_TYPE__) throw () __attribute__((malloc));
21
 
22
  void abort (void) throw (); // these aren't
23
  void _exit (int) throw (); // { dg-error "std::_exit" }
24
 
25
  extern "C" void c1 (void) throw ();
26
  void C1 (void) throw (); // { dg-error "std::C1" }
27
 
28
  extern "C" void c2 (void) throw ();
29
  void C2 (void) throw ();
30
 
31
  extern "C" void c3 (void) throw ();
32
  void C3 (void) throw (); // { dg-error "std::C3" }
33
}
34
 
35
namespace other {
36
  extern "C" void c3 (void) throw ();
37
  void C3 (void) throw (); // { dg-error "other::C3" }
38
}
39
 
40
using std::exit;
41
using std::_exit;
42
using std::c1;
43
using std::C1;
44
 
45
  extern "C" void exit (int) throw ();
46
  extern "C" void *malloc (__SIZE_TYPE__) throw () __attribute__((malloc));
47
 
48
  void abort (void) throw ();
49
  void _exit (int) throw (); // { dg-error "conflicts|void _exit" }
50
 
51
  extern "C" void c1 (void) throw ();
52
  void C1 (void) throw (); // { dg-error "conflicts|void C1" }
53
 
54
  extern "C" void c2 (void) throw ();
55
  void C2 (void) throw ();
56
 
57
  int C3 (int) throw ();
58
 
59
using std::malloc;
60
using std::abort; // { dg-error "already declared" }
61
using std::c2;
62
using std::C2; // { dg-error "already declared" }
63
 
64
using std::c3; using other::c3;
65
using std::C3; using other::C3;
66
 
67
  long C3 (long) throw ();
68
 
69
int main () {
70
  malloc (0);
71
  exit (0);
72
 
73
  _exit (0); // { dg-error "ambiguous" }
74
  abort ();
75
 
76
  c1 ();
77
  C1 (); // { dg-error "ambiguous" }
78
 
79
  c2 ();
80
  C2 (); // one might expect an ambiguous call error here as well, but
81
         // we don't add the using decl if we find it to be in error.
82
 
83
  c3 ();
84
  C3 (); // { dg-error "ambiguous" }
85
  C3 (0);
86
  C3 (0l);
87
}

powered by: WebSVN 2.1.0

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