Test cases
Martin von Loewis
martin@mira.isdn.cs.tu-berlin.de
Wed Jul 1 13:08:00 GMT 1998
Here is a collection of test cases that I've been using for the
namespace stuff.
Martin
--- /dev/null Mon Jul 18 01:46:18 1994
+++ g++.ns/alias2.C Sat Jun 27 14:50:18 1998
@@ -0,0 +1,8 @@
+//Build don't link:
+namespace NS1
+{
+ int a;
+}
+
+namespace NS2 = NonExistant; //ERROR -
+
--- /dev/null Mon Jul 18 01:46:18 1994
+++ g++.ns/alias5.C Sat May 9 20:08:51 1998
@@ -0,0 +1,18 @@
+namespace foo{
+ int eine_funktion(int)
+ {
+ return 0;
+ }
+}
+
+namespace foo{
+ void eine_funktion(int,int)
+ {}
+}
+
+namespace bar = foo;
+
+int main()
+{
+ return bar::eine_funktion(3);
+}
--- /dev/null Mon Jul 18 01:46:18 1994
+++ g++.ns/koenig4.C Wed Jul 1 21:35:38 1998
@@ -0,0 +1,24 @@
+void f();
+void f(int);
+
+namespace A{
+ struct S{
+ void f();
+ void f(S);
+ };
+ void f(S&){}
+ void h(S&){}
+}
+
+template<class T>
+void g(T t){
+ f(t);
+}
+
+int main()
+{
+ A::S s;
+ f(s);
+ g(s);
+ h(s);
+}
--- /dev/null Mon Jul 18 01:46:18 1994
+++ g++.ns/lookup3.C Sun Jun 28 23:06:07 1998
@@ -0,0 +1,14 @@
+namespace A{
+ int i;
+ int f();
+}
+
+int A::f()
+{
+ return i;
+}
+
+main()
+{
+ return A::f();
+}
--- /dev/null Mon Jul 18 01:46:18 1994
+++ g++.ns/ns13.C Tue Apr 21 22:26:28 1998
@@ -0,0 +1,13 @@
+namespace std{
+ void f(){}
+ void g();
+ int i=5;
+}
+
+void std::g()
+{}
+
+main()
+{
+ return std::i-5;
+}
--- /dev/null Mon Jul 18 01:46:18 1994
+++ g++.ns/ns14.C Wed Apr 15 23:01:34 1998
@@ -0,0 +1,16 @@
+//Special g++ Options: -fhonor-std
+namespace std{
+ int f(){
+ return 0;
+ }
+}
+
+int f()
+{
+ return 1;
+}
+
+int main()
+{
+ return std::f();
+}
--- /dev/null Mon Jul 18 01:46:18 1994
+++ g++.ns/ns15.C Tue Apr 14 22:55:28 1998
@@ -0,0 +1,2 @@
+//Build don't link:
+namespace std {}
--- /dev/null Mon Jul 18 01:46:18 1994
+++ g++.ns/template3.C Tue Apr 21 09:01:18 1998
@@ -0,0 +1,21 @@
+//Check instantiation of templates outside their namespace
+namespace A{
+template <class T>void g(){}
+template <class T> struct B {
+ B(){
+ f();
+ }
+ void f()
+ {
+ g<T>();
+ }
+};
+}
+
+template class A::B<int>;
+A::B<int> s;
+
+int main()
+{
+ return 0;
+}
--- /dev/null Mon Jul 18 01:46:18 1994
+++ g++.ns/undef1.C Sat May 30 17:01:53 1998
@@ -0,0 +1,5 @@
+//Build don't link:
+namespace A{
+}
+
+struct Y: A::S<int>{}; //ERROR - no such type
--- /dev/null Mon Jul 18 01:46:18 1994
+++ g++.ns/using4.C Sun Jun 28 22:58:05 1998
@@ -0,0 +1,5 @@
+//Build don't link
+#include <vector>
+namespace csp {
+using namespace std::vector; // ERROR - vector is not a namespace
+}
--- /dev/null Mon Jul 18 01:46:18 1994
+++ g++.ns/using5.C Sun Jun 28 22:59:52 1998
@@ -0,0 +1,6 @@
+// Build don't link:
+namespace a {
+ class b {
+ using std::c; //ERROR - namespace using on class level
+ };
+}
--- /dev/null Mon Jul 18 01:46:18 1994
+++ g++.ns/using6.C Sun Jun 28 23:01:36 1998
@@ -0,0 +1,9 @@
+//Build don't link:
+#include <vector>
+
+namespace csp {
+ using namespace std;
+ struct X {
+ vector<int> v;
+ };
+}
--- /dev/null Mon Jul 18 01:46:18 1994
+++ g++.ns/using7.C Sun Jun 28 23:10:01 1998
@@ -0,0 +1,11 @@
+namespace X{
+ void f(int){}
+}
+
+void f();
+
+int main()
+{
+ using X::f;
+ f(3);
+}
More information about the Gcc-patches
mailing list