summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/overload/using2.C
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/g++.dg/overload/using2.C
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/g++.dg/overload/using2.C')
-rw-r--r--gcc/testsuite/g++.dg/overload/using2.C92
1 files changed, 92 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/overload/using2.C b/gcc/testsuite/g++.dg/overload/using2.C
new file mode 100644
index 000000000..514d83f34
--- /dev/null
+++ b/gcc/testsuite/g++.dg/overload/using2.C
@@ -0,0 +1,92 @@
+// { dg-do compile }
+
+// Copyright 2005 Free Software Foundation
+// by Alexandre Oliva <aoliva@redhat.com>
+// based on https://bugzilla.redhat.com/beta/show_bug.cgi?id=149098
+
+// Per the ISO C++ 90 Standard, using declarations before of after a
+// declaration of the same function name and prototype should be
+// errors (7.3.3/11). However, DR 101's resolution recommends
+// accepting such duplicates if they denote the same function, which
+// means extern "C" declarations are supposed to match and be
+// accepted.
+
+// This test makes sure we reject or accept regular and using
+// declarations regardless of order as appropriate, and that having
+// built-in declarations or overloads doesn't affet the outcome.
+
+namespace std {
+ extern "C" void exit (int) throw (); // these are built-in (extern "C")
+ extern "C" void *malloc (__SIZE_TYPE__) throw () __attribute__((malloc));
+
+ void abort (void) throw (); // these aren't
+ void _exit (int) throw (); // { dg-message "std::_exit" }
+
+ extern "C" void c1 (void) throw ();
+ void C1 (void) throw (); // { dg-message "std::C1" }
+
+ extern "C" void c2 (void) throw ();
+ void C2 (void) throw ();
+
+ extern "C" void c3 (void) throw ();
+ void C3 (void) throw (); // { dg-message "std::C3" }
+}
+
+namespace other {
+ extern "C" void c3 (void) throw ();
+ void C3 (void) throw (); // { dg-message "other::C3" }
+}
+
+using std::exit;
+using std::_exit;
+using std::c1;
+using std::C1;
+
+ extern "C" void exit (int) throw ();
+ extern "C" void *malloc (__SIZE_TYPE__) throw () __attribute__((malloc));
+
+ void abort (void) throw ();
+ void _exit (int) throw (); // { dg-error "conflicts" "conflicts" }
+ // { dg-message "void _exit" "_exit" { target *-*-* } 49 }
+
+ extern "C" void c1 (void) throw ();
+ void C1 (void) throw (); // { dg-error "conflicts" "conflicts" }
+ // { dg-message "void C1" "C1" { target *-*-* } 53 }
+
+ extern "C" void c2 (void) throw ();
+ void C2 (void) throw ();
+
+ int C3 (int) throw ();
+
+using std::malloc;
+using std::abort; // { dg-error "already declared" }
+using std::c2;
+using std::C2; // { dg-error "already declared" }
+
+using std::c3; using other::c3;
+using std::C3; using other::C3;
+
+ long C3 (long) throw ();
+
+int main () {
+ malloc (0);
+ exit (0);
+
+ _exit (0); // { dg-error "ambiguous" }
+ // { dg-message "candidate" "candidate note" { target *-*-* } 75 }
+ abort ();
+
+ c1 ();
+ C1 (); // { dg-error "ambiguous" }
+ // { dg-message "candidate" "candidate note" { target *-*-* } 80 }
+
+ c2 ();
+ C2 (); // one might expect an ambiguous call error here as well, but
+ // we don't add the using decl if we find it to be in error.
+
+ c3 ();
+ C3 (); // { dg-error "ambiguous" }
+ // { dg-message "candidate" "candidate note" { target *-*-* } 88 }
+ C3 (0);
+ C3 (0l);
+}