-// GROUPS passed operator-new
-#include <stdio.h>
-#include <stdlib.h>
-
-int pass = 0;
-
-void *operator new(size_t sz){
-
- void *p;
-
- pass = 1;
- p = malloc(sz);
- return p;
-}
-
-class A {
-public:
- A() {}
- ~A() {}
-
- int a;
- int b;
-};
-
-
-int main()
-{
- A *bb = new A[10];
- delete [] bb;
-
- if (pass)
- printf ("PASS\n");
- else
- printf ("FAIL\n");
-}
+#include <new>
+void *operator new(size_t sz) throw (std::bad_alloc) {
-// Build don't link:
-// GROUPS passed visibility
-// Used to say:
-// manip.cc:17: member `_f' is a private member of class `B<int>'
-// manip.cc:17: member `_a' is a private member of class `B<int>'
-
-class A {};
-
-template <class TP>
-class B
-{
- A &(*_f) (A &, TP);
- TP _a;
-public:
- B (A &(*f) (A &, TP), TP a) : _f (f), _a (a) {}
- friend A &operator<< (A &o, const B<TP> &m);
-};
-
-template <class TP>
-inline A &
-operator<< (A &o, const B<TP> &m)
-{
- (*m._f) (o, m._a);
- return o;
-}
-
-A &setw (A &, int);
-B<int> setw (int n)
-{
- return B<int> (setw, n);
-}
-
-A x;
-
-void f ()
-{
- x << setw (2);
-}
+ friend A &operator<< <>(A &o, const B<TP> &m);
-// Bug: new doesn't make sure that the count is an integral value.
-
-typedef __SIZE_TYPE__ size_t;
-extern "C" int printf (const char *, ...);
-extern "C" void *malloc (size_t);
-size_t s;
-
-void * operator new (size_t siz) {
- if (s == 0)
- s = siz;
- else
- s = (s != siz);
- return malloc (siz);
-}
-
-main()
-{
- s = 0;
-
- float f = 3;
- int* b1 = new int[(int)f];
- int* b2 = new int[f];
-
- return s;
-}
+#include <new>
+void * operator new (size_t siz) throw (std::bad_alloc) {
-// Build don't link:
-// GROUPS passed overloading
-enum bar {};
-
-void operator+ (int, int);// ERROR - .*
-void operator+ (bar&, int);
-
-template <class T> void operator+ (int b, T& t) { return b; }
-void operator+ (int, bar&);
-
-template <class T> class foo
-{
-public:
- friend void operator+ (int, T&);
-};
-
-class baz;
-
-class foo<int>;
-class foo<baz>;
+ friend void operator+ <> (int, T&);
-// PRMS Id: 4257 (second bug)
-// Bug: g++ fails to recognize multiple previous instantiations of a function
-// template.
-// Build don't link:
-
-template <class T>
-class A {
- int i;
-
- friend int foo (A<T>&);
-};
-
-template <class T> int foo (A<T>& a) { return a.i; }
-
-A<int> a;
-A<char> dummy;
-
-void bar ()
-{
- foo (a); // gets bogus error - two foo(A<int>&)'s
-}
+// Special g++ Options: -fguiding-decls
-// Bug: member operator shadows global template in tsubst.
-// Build don't link:
-
-class ostream;
-
-template <class TP> class smanip {
-public:
- friend ostream& operator<<(ostream &o, const smanip<TP>&m);
-};
-
-template<class TP>
-ostream& operator<<(ostream& o, const smanip<TP>& m)
-{ return o;}
-
-class X
-{
-public:
- X operator<<(int); // commenting out this line makes it work!
- void print(ostream& os);
-};
-
-void X::print(ostream& os)
-{
- smanip<double> smd;
- os << smd; // gets bogus error
-}
+ friend ostream& operator<< <>(ostream &o, const smanip<TP>&m);
-// Build don't link:
-// GROUPS passed friends
-// friends file
-// From: rwave!myersn%rwave.roguewave@cs.orst.edu (Nathan Myers)
-// Date: Thu, 17 Dec 92 16:33 PST
-// Subject: 2.3.2: friend decl of new confuses constructor
-// Message-ID: <m0n2Vec-0000GrC@rwave.roguewave.com>
-
-#include <stddef.h>
-struct Foo {
- friend void* operator new(size_t);
- friend void operator delete(void*) throw ();
- Foo();
- ~Foo();
-};
-Foo::Foo() { }
-Foo::~Foo() { }
+#include <new>
+ friend void* operator new(size_t) throw (std::bad_alloc);
-#include <iostream.h>
-#include <stddef.h>
-
-int fail = 1;
-
-static void *operator new(size_t size) {
- --fail;
- return (void*) 0;
-}
-
-main() {
- cout << "";
- new int;
- return fail;
-}
+#include <new>
+static void *operator new(size_t size) throw (std::bad_alloc) {
-// It checks to see if you can define your own global new operator.
-// prms-id: 755
-
-typedef __SIZE_TYPE__ size_t;
-extern "C" void exit(int);
-
-void* operator new(size_t sz) {
- void* p = 0;
- exit(0);
- return p;
-}
-
-main () {
- int* i = new int;
- delete i;
- return 1;
-}
+#include <new>
+void* operator new(size_t sz) throw (std::bad_alloc) {
--- /dev/null
+// Build don't link:
+
+template <class T>
+struct A
+{
+ typedef T A_Type;
+};
+
+
+template <class U>
+struct B : public A<U>
+{
+};
+
+
+template <class U>
+struct C : public B<U>
+{
+ A_Type Func();
+};
+
+
+template <class U>
+C<U>::A_Type C<U>::Func()
+{
+}
--- /dev/null
+// Build don't link:
+
+template <class T>
+struct A
+{
+ typedef T A_Type;
+};
+
+
+template <class U>
+struct B : public A<U>
+{
+};
+
+
+template <class U>
+struct C : public B<U>
+{
+ void Func(A_Type);
+};
+
+
+template <class U>
+void C<U>::Func(A_Type)
+{
+}
--- /dev/null
+// Build don't link:
+
+template <class T>
+struct A
+{
+ typedef T A_Type;
+};
+
+
+template <class U>
+struct B : public A<U>
+{
+ A_Type Func();
+};
+
+
+template <class U>
+A<U>::A_Type B<U>::Func()
+{
+}