aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/g++.old-deja/g++.brendan/misc12.C16
-rw-r--r--gcc/testsuite/g++.old-deja/g++.ext/pretty4.C84
-rw-r--r--gcc/testsuite/g++.old-deja/g++.pt/memtemp77.C8
4 files changed, 94 insertions, 20 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 44dd18a..ddb1dbc 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,11 @@
2000-03-08 Nathan Sidwell <nathan@codesourcery.com>
+ * g++.old-deja/g++.brendan/misc12.C: Removed.
+ * g++.old-deja/g++.pt/memtemp77.C: Constify.
+ * g++.old-deja/g++.ext/pretty4.C: New test.
+
+2000-03-08 Nathan Sidwell <nathan@codesourcery.com>
+
* g++.old-deja/g++.other/string2.C: New test.
2000-03-06 Nathan Sidwell <nathan@codesourcery.com>
diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/misc12.C b/gcc/testsuite/g++.old-deja/g++.brendan/misc12.C
deleted file mode 100644
index 6dd31d0..0000000
--- a/gcc/testsuite/g++.old-deja/g++.brendan/misc12.C
+++ /dev/null
@@ -1,16 +0,0 @@
-// GROUPS passed miscellaneous
-extern "C" void exit (int);
-extern "C" int printf (const char *, ...);
-
-/* Make sure cp-lex.c handles these properly--if this links, that means
- it emitted the strings instead of __FUNCTION__.0, etc. */
-
-int
-main()
-{
- char *a = __FUNCTION__;
- char *b = __PRETTY_FUNCTION__;
-
- printf ("PASS\n");
- exit (0);
-}
diff --git a/gcc/testsuite/g++.old-deja/g++.ext/pretty4.C b/gcc/testsuite/g++.old-deja/g++.ext/pretty4.C
new file mode 100644
index 0000000..fd6b0e0
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.ext/pretty4.C
@@ -0,0 +1,84 @@
+// Copyright (C) 2000 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 3 Mar 2000 <nathan@codesourcery.com>
+
+// __PRETTY_FUNCTION__, __FUNCTION__ and __function__ should have the
+// type char const [X], where X is the right value for that particular function
+
+static void const *strings[4];
+static void const *tpls[4];
+static unsigned pos = 0;
+static int fail;
+static void const *ptr = 0;
+
+void unover (char const (*)[5]) {}
+void foo (char const (*)[5]) {}
+void foo (void *) {fail = 1;}
+void foo (void const *) {fail = 1;}
+void baz (char const (&)[5]) {}
+
+template<unsigned I> void PV (char const (&objRef)[I])
+{
+ strings[pos] = objRef;
+ tpls[pos] = __PRETTY_FUNCTION__;
+ pos++;
+}
+
+void fn ()
+{
+ PV (__FUNCTION__);
+ PV (__func__);
+ PV (__PRETTY_FUNCTION__);
+ PV ("wibble");
+}
+
+void baz ()
+{
+ ptr = __FUNCTION__;
+ // there should be no string const merging
+ if (ptr == "baz")
+ fail = 1;
+ // but all uses should be the same.
+ if (ptr != __FUNCTION__)
+ fail = 1;
+}
+int baz (int)
+{
+ return ptr == __FUNCTION__;
+}
+
+int main ()
+{
+ // make sure we actually emit the VAR_DECL when needed, and things have the
+ // expected type.
+ foo (&__FUNCTION__);
+ baz (__FUNCTION__);
+ unover (&__FUNCTION__);
+ if (fail)
+ return 1;
+
+ // __FUNCTION__ should be unique across functions with the same base name
+ // (it's a local static, _not_ a string).
+ baz ();
+ if (fail)
+ return 1;
+ if (baz (1))
+ return 1;
+ fn ();
+
+ // Check the names of fn. They should all be distinct strings (though two
+ // will have the same value).
+ if (strings[0] == strings[1])
+ return 1;
+ if (strings[0] == strings[2])
+ return 1;
+ if (strings[1] == strings[2])
+ return 1;
+
+ // check the names of the template functions so invoked
+ if (tpls[0] != tpls[1])
+ return 1;
+ if (tpls[0] == tpls[2])
+ return 1;
+
+ return 0;
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp77.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp77.C
index 827e2df..d907367 100644
--- a/gcc/testsuite/g++.old-deja/g++.pt/memtemp77.C
+++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp77.C
@@ -4,21 +4,21 @@ template <class T>
struct S3
{
template <class U>
- static char* h(U);
+ static const char* h(U);
};
template <>
template <>
-char* S3<double>::h(int) { return __PRETTY_FUNCTION__; }
+const char* S3<double>::h(int) { return __PRETTY_FUNCTION__; }
template <>
template <>
-char* S3<char>::h(int) { return __PRETTY_FUNCTION__; }
+const char* S3<char>::h(int) { return __PRETTY_FUNCTION__; }
int main()
{
if (strcmp (S3<double>::h(7),
- "char *S3<T>::h (U) [with U = int, T = double]") == 0)
+ "const char *S3<T>::h (U) [with U = int, T = double]") == 0)
return 0;
else
return 1;