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
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.
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" }
36 extern "C" void c3 (void) throw ();
37 void C3 (void) throw (); // { dg-error "other::C3" }
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 ();
60 using std::abort; // { dg-error "already declared" }
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 ();
73 _exit (0); // { dg-error "ambiguous" }
77 C1 (); // { dg-error "ambiguous" }
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.
84 C3 (); // { dg-error "ambiguous" }