Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / gcc / testsuite / g++.dg / overload / using2.C
blob2ecb5fad6b0170429286f3c575ef6fc0ab874cc3
1 // { dg-do compile }
3 // Copyright 2005 Free Software Foundation
4 // by Alexandre Oliva <aoliva@redhat.com>
5 // based on https://bugzilla.redhat.com/beta/show_bug.cgi?id=149098
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.
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.
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));
22   void abort (void) throw (); // these aren't
23   void _exit (int) throw (); // { dg-error "std::_exit" }
25   extern "C" void c1 (void) throw ();
26   void C1 (void) throw (); // { dg-error "std::C1" }
28   extern "C" void c2 (void) throw ();
29   void C2 (void) throw ();
31   extern "C" void c3 (void) throw ();
32   void C3 (void) throw (); // { dg-error "std::C3" }
35 namespace other {
36   extern "C" void c3 (void) throw ();
37   void C3 (void) throw (); // { dg-error "other::C3" }
40 using std::exit;
41 using std::_exit;
42 using std::c1;
43 using std::C1;
45   extern "C" void exit (int) throw ();
46   extern "C" void *malloc (__SIZE_TYPE__) throw () __attribute__((malloc));
48   void abort (void) throw ();
49   void _exit (int) throw (); // { dg-error "conflicts|void _exit" }
51   extern "C" void c1 (void) throw ();
52   void C1 (void) throw (); // { dg-error "conflicts|void C1" }
54   extern "C" void c2 (void) throw ();
55   void C2 (void) throw ();
57   int C3 (int) throw ();
59 using std::malloc;
60 using std::abort; // { dg-error "already declared" }
61 using std::c2;
62 using std::C2; // { dg-error "already declared" }
64 using std::c3; using other::c3;
65 using std::C3; using other::C3;
67   long C3 (long) throw ();
69 int main () {
70   malloc (0);
71   exit (0);
73   _exit (0); // { dg-error "ambiguous" }
74   abort ();
76   c1 ();
77   C1 (); // { dg-error "ambiguous" }
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.
83   c3 ();
84   C3 (); // { dg-error "ambiguous" }
85   C3 (0);
86   C3 (0l);