aboutsummaryrefslogtreecommitdiff
path: root/src/cctest
diff options
context:
space:
mode:
authorjthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5>2002-09-29 15:50:55 +0000
committerjthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5>2002-09-29 15:50:55 +0000
commitf90849f3ccd99793b71eb19d9c8f9a8c5f628158 (patch)
tree932879d6af271c462a54021e54943c0c50b04a9c /src/cctest
parent2394f16091c390daad300f52276f44103baaf735 (diff)
new version of C++ namespace portability tests
-- test more different ways of organizing the code -- new naming scheme -- subdirectories to reduce file clutter git-svn-id: http://svn.einsteintoolkit.org/cactus/EinsteinAnalysis/AHFinderDirect/trunk@776 f88db872-0e4f-0410-b76b-b9085cfa78c5
Diffstat (limited to 'src/cctest')
-rw-r--r--src/cctest/README2
-rw-r--r--src/cctest/namespace/README28
-rw-r--r--src/cctest/namespace/cstdio-global.cc10
-rw-r--r--src/cctest/namespace/cstdio-std:std-printf.cc10
-rw-r--r--src/cctest/namespace/cstdio-std:using-namespace-std.cc11
-rw-r--r--src/cctest/namespace/cstdio-std:using-std-printf.cc11
-rw-r--r--src/cctest/namespace/makefile58
-rw-r--r--src/cctest/namespace/status52
-rw-r--r--src/cctest/namespace/stdio_h-global.cc10
-rw-r--r--src/cctest/namespace/stdio_h-std:std-printf.cc10
-rw-r--r--src/cctest/namespace/stdio_h-std:using-namespace-std.cc11
-rw-r--r--src/cctest/namespace/stdio_h-std:using-std-printf.cc11
12 files changed, 224 insertions, 0 deletions
diff --git a/src/cctest/README b/src/cctest/README
new file mode 100644
index 0000000..2d515a0
--- /dev/null
+++ b/src/cctest/README
@@ -0,0 +1,2 @@
+This directory contains subdirectories with test programs for
+various C++ compiler/library features.
diff --git a/src/cctest/namespace/README b/src/cctest/namespace/README
new file mode 100644
index 0000000..e8fe2a8
--- /dev/null
+++ b/src/cctest/namespace/README
@@ -0,0 +1,28 @@
+$Header$
+
+This directory contains a set of "hello, world" programs to test how
+the C++ namespaces are handled for standard library functions.
+
+Each .cc file is a "hello, world\n" program using a particular set of
+options for what header file to #include, what (if any) using declarations
+or definitions to use, and whether or not to use an explicit std::
+qualifier when calling printf().
+
+According to standard C++, #include <cstdio> puts names *only* in the
+std:: namespace, so the cstdio-global.cc program should fail to compile.
+All the other programs should be legal in standard C++.
+
+ what to what namespace how we call status
+ #include? are we using printf()? in
+ printf() in? standard
+ using? C++
+
+stdio_h-global.cc <stdio.h> global -- printf() ok
+stdio_h-std:std-printf.cc <stdio.h> std -- std::printf() ok
+stdio_h-std:using-std-printf.cc <stdio.h> std std::printf; printf() ok
+stdio_h-std:using-namespace-std.cc <stdio.h> std namespace std; printf() ok
+
+cstdio-global.cc <cstdio> global -- printf() WRONG
+cstdio-std:std-printf.cc <cstdio> std -- std::printf() ok
+cstdio-std:using-std-printf.cc <cstdio> std std::printf; printf() ok
+cstdio-std:using-namespace-std.cc <cstdio> std namespace std; printf() ok
diff --git a/src/cctest/namespace/cstdio-global.cc b/src/cctest/namespace/cstdio-global.cc
new file mode 100644
index 0000000..60b04c7
--- /dev/null
+++ b/src/cctest/namespace/cstdio-global.cc
@@ -0,0 +1,10 @@
+// $Header$
+
+#include <cstdio>
+
+int main()
+{
+printf("testing <cstdio> functions in global namespace (THIS SHOULD FAIL):\n");
+printf("==> #include <cstdio>; printf() is ok (THIS SHOULD FAIL)\n");
+return 0;
+}
diff --git a/src/cctest/namespace/cstdio-std:std-printf.cc b/src/cctest/namespace/cstdio-std:std-printf.cc
new file mode 100644
index 0000000..3dcff15
--- /dev/null
+++ b/src/cctest/namespace/cstdio-std:std-printf.cc
@@ -0,0 +1,10 @@
+// $Header$
+
+#include <cstdio>
+
+int main()
+{
+std::printf("testing <cstdio> functions in std:: namespace:\n");
+std::printf("==> #include <cstdio>; std::printf() is ok\n");
+return 0;
+}
diff --git a/src/cctest/namespace/cstdio-std:using-namespace-std.cc b/src/cctest/namespace/cstdio-std:using-namespace-std.cc
new file mode 100644
index 0000000..0fbf9c6
--- /dev/null
+++ b/src/cctest/namespace/cstdio-std:using-namespace-std.cc
@@ -0,0 +1,11 @@
+// $Header$
+
+#include <cstdio>
+using namespace std;
+
+int main()
+{
+printf("testing <cstdio> functions in std:: namespace:\n");
+printf("==> #include <cstdio>; using namespace std; printf() is ok\n");
+return 0;
+}
diff --git a/src/cctest/namespace/cstdio-std:using-std-printf.cc b/src/cctest/namespace/cstdio-std:using-std-printf.cc
new file mode 100644
index 0000000..542f482
--- /dev/null
+++ b/src/cctest/namespace/cstdio-std:using-std-printf.cc
@@ -0,0 +1,11 @@
+// $Header$
+
+#include <cstdio>
+using std::printf;
+
+int main()
+{
+printf("testing <cstdio> functions in std:: namespace:\n");
+printf("==> #include <cstdio>; using std::printf; printf() is ok\n");
+return 0;
+}
diff --git a/src/cctest/namespace/makefile b/src/cctest/namespace/makefile
new file mode 100644
index 0000000..0c76e63
--- /dev/null
+++ b/src/cctest/namespace/makefile
@@ -0,0 +1,58 @@
+# Makefile to test various C/C++ compiler features
+#
+# Targets:
+# default test namespace handling for <stdio.h> and <cstdio>
+# stdio_h test namespace handling for <stdio.h>
+# cstdio test namespace handling for <cstdio>
+# clean remove all binaries
+#
+# Arguments:
+# CXX how to invoke the C++ compiler, including any desired flags
+#
+
+# default setting, may be overridden from command line
+CXX := gcc -W -Wall -pedantic -ansi
+
+.PHONY : default
+default : stdio_h cstdio
+
+.PHONY : stdio_h
+stdio_h :
+ -$(CXX) -o stdio_h-global \
+ stdio_h-global.cc
+ -./stdio_h-global
+ -$(CXX) -o stdio_h-std:std-printf \
+ stdio_h-std:std-printf.cc
+ -./stdio_h-std:std-printf
+ -$(CXX) -o stdio_h-std:using-std-printf \
+ stdio_h-std:using-std-printf.cc
+ -./stdio_h-std:using-std-printf
+ -$(CXX) -o stdio_h-std:using-namespace-std \
+ stdio_h-std:using-namespace-std.cc
+ -./stdio_h-std:using-namespace-std
+
+.PHONY : cstdio
+cstdio :
+ -$(CXX) -o cstdio-global \
+ cstdio-global.cc
+ -./cstdio-global
+ -$(CXX) -o cstdio-std:std-printf \
+ cstdio-std:std-printf.cc
+ -./cstdio-std:std-printf
+ -$(CXX) -o cstdio-std:using-std-printf \
+ cstdio-std:using-std-printf.cc
+ -./cstdio-std:using-std-printf
+ -$(CXX) -o cstdio-std:using-namespace-std \
+ cstdio-std:using-namespace-std.cc
+ -./cstdio-std:using-namespace-std
+
+.PHONY : clean
+clean :
+ -rm -f stdio_h-global \
+ stdio_h-std:std-printf \
+ stdio_h-std:using-std-printf \
+ stdio_h-std:using-namespace-std
+ -rm -f cstdio-global \
+ cstdio-std:std-printf \
+ cstdio-std:using-std-printf \
+ cstdio-std:using-namespace-std
diff --git a/src/cctest/namespace/status b/src/cctest/namespace/status
new file mode 100644
index 0000000..d509e33
--- /dev/null
+++ b/src/cctest/namespace/status
@@ -0,0 +1,52 @@
+osmium.aei.mpg.de # OpenBSD 3.1
+gcc version 2.95.3 20010125 (prerelease)
+Sun Sep 29 11:32:19 EDT 2002
+CXX='/usr/bin/g++ -W -Wall -ansi -pedantic'
+==> #include <stdio.h>; printf() is ok
+==> #include <stdio.h>; std::printf() is ok
+==> #include <stdio.h>; using std::printf; printf() is ok
+==> #include <stdio.h>; using namespace std; printf() is ok
+==> #include <cstdio>; printf() is ok (THIS SHOULD FAIL)
+==> #include <cstdio>; std::printf() is ok
+==> #include <cstdio>; using std::printf; printf() is ok
+==> #include <cstdio>; using namespace std; printf() is ok
+
+xeon21.aei.mpg.de
+gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-98)
+Wed Sep 25 20:01:31 CEST 2002
+CXX='gcc -W -Wall -pedantic -ansi'
+==> <stdio.h> fns in the global namespace are ok
+==> <stdio.h> fns in the std:: namespace are ok
+==> THIS SHOULD FAIL: <cstdio> fns in global namespace are ok
+==> <cstdio> fns in std:: namespace are ok
+
+xeon21.aei.mpg.de
+gcc version 3.2
+Thu Sep 26 01:37:04 CEST 2002
+CXX='/scratch/jthorn/local/bin/g++ -Wall -pedantic -ansi'
+==> <stdio.h> fns in the global namespace are ok
+==> THIS SHOULD FAIL: <cstdio> fns in global namespace are ok
+==> <cstdio> fns in std:: namespace are ok
+
+xeon21.aei.mpg.de
+Intel(R) C++ Compiler for 32-bit applications, Version 5.0.1 Build 010730D0
+Wed Sep 25 20:03:47 CEST 2002
+CXX='icc -Xc'
+==> <stdio.h> fns in the global namespace are ok
+==> THIS SHOULD FAIL: <cstdio> fns in global namespace are ok
+==> <cstdio> fns in std:: namespace are ok
+
+xeon21.aei.mpg.de
+Intel(R) C++ Compiler for 32-bit applications, Version 5.0.1 Build 010730D0
+Wed Sep 25 20:25:55 CEST 2002
+CXX='icc -ansi -Xc'
+==> <stdio.h> fns in the global namespace are ok
+==> THIS SHOULD FAIL: <cstdio> fns in global namespace are ok
+==> <cstdio> fns in std:: namespace are ok
+
+origin.aei.mpg.de
+MIPSpro Compilers: Version 7.3.1.2m
+Wed Sep 25 20:00:36 CEST 2002
+CXX='CC -LANG:std'
+==> <stdio.h> fns in the global namespace are ok
+all others fail
diff --git a/src/cctest/namespace/stdio_h-global.cc b/src/cctest/namespace/stdio_h-global.cc
new file mode 100644
index 0000000..bd31900
--- /dev/null
+++ b/src/cctest/namespace/stdio_h-global.cc
@@ -0,0 +1,10 @@
+// $Header$
+
+#include <stdio.h>
+
+int main()
+{
+printf("testing <stdio.h> functions in global namespace:\n");
+printf("==> #include <stdio.h>; printf() is ok\n");
+return 0;
+}
diff --git a/src/cctest/namespace/stdio_h-std:std-printf.cc b/src/cctest/namespace/stdio_h-std:std-printf.cc
new file mode 100644
index 0000000..f45bf4b
--- /dev/null
+++ b/src/cctest/namespace/stdio_h-std:std-printf.cc
@@ -0,0 +1,10 @@
+// $Header$
+
+#include <stdio.h>
+
+int main()
+{
+std::printf("testing <stdio.h> functions in std:: namespace:\n");
+std::printf("==> #include <stdio.h>; std::printf() is ok\n");
+return 0;
+}
diff --git a/src/cctest/namespace/stdio_h-std:using-namespace-std.cc b/src/cctest/namespace/stdio_h-std:using-namespace-std.cc
new file mode 100644
index 0000000..ce2230a
--- /dev/null
+++ b/src/cctest/namespace/stdio_h-std:using-namespace-std.cc
@@ -0,0 +1,11 @@
+// $Header$
+
+#include <stdio.h>
+using namespace std;
+
+int main()
+{
+printf("testing <stdio.h> functions in std:: namespace:\n");
+printf("==> #include <stdio.h>; using namespace std; printf() is ok\n");
+return 0;
+}
diff --git a/src/cctest/namespace/stdio_h-std:using-std-printf.cc b/src/cctest/namespace/stdio_h-std:using-std-printf.cc
new file mode 100644
index 0000000..139b523
--- /dev/null
+++ b/src/cctest/namespace/stdio_h-std:using-std-printf.cc
@@ -0,0 +1,11 @@
+// $Header$
+
+#include <stdio.h>
+using std::printf;
+
+int main()
+{
+printf("testing <stdio.h> functions in std:: namespace:\n");
+printf("==> #include <stdio.h>; using std::printf; printf() is ok\n");
+return 0;
+}