Commit 6e940d05 by Jason Merrill

new, update

From-SVN: r19649
parent f283421d
// g++ 1.37.1 bug 900404_04 // g++ 1.37.1 bug 900404_04
// The ANSI C does not allow vacuous statements (i.e. just semicolons) // [dcl.dcl] explains that simple-declarations may omit the
// at the file-scope level. // init-declarator-list only if the decl-specifier-seq declares a
// class, i.e. if it contains a class-specifier, an
// The current C++ Reference Manual does not indicate whether these should // elaborated-type-specifier with class key, or an enum-specifier. The
// be considered legal or not. // declaration below contains neither.
// I am forced to conclude that C++ will follow ANSI C in this regard,
// and that these are therefore not legal.
// g++ fails to flag errors for such usage. // g++ fails to flag errors for such usage.
......
...@@ -33,6 +33,6 @@ eh_test (int level) ...@@ -33,6 +33,6 @@ eh_test (int level)
main () main ()
{ {
set_terminate (&eh_terminate); std::set_terminate (&eh_terminate);
eh_test (0); eh_test (0);
} }
...@@ -8,15 +8,15 @@ void my_term () { exit (1); } ...@@ -8,15 +8,15 @@ void my_term () { exit (1); }
void my_unexp () { throw 42; } void my_unexp () { throw 42; }
void void
f () throw (char, int, bad_exception) f () throw (char, int, std::bad_exception)
{ {
throw 'a'; throw 'a';
} }
main () main ()
{ {
set_terminate (my_term); std::set_terminate (my_term);
set_unexpected (my_unexp); std::set_unexpected (my_unexp);
try try
{ {
...@@ -30,7 +30,7 @@ main () ...@@ -30,7 +30,7 @@ main ()
{ {
return 3; return 3;
} }
catch (bad_exception) catch (std::bad_exception)
{ {
return 4; return 4;
} }
......
...@@ -8,15 +8,15 @@ void my_term () { exit (1); } ...@@ -8,15 +8,15 @@ void my_term () { exit (1); }
void my_unexp () { throw 42; } void my_unexp () { throw 42; }
void void
f () throw (int, bad_exception) f () throw (int, std::bad_exception)
{ {
throw 'a'; throw 'a';
} }
main () main ()
{ {
set_terminate (my_term); std::set_terminate (my_term);
set_unexpected (my_unexp); std::set_unexpected (my_unexp);
try try
{ {
...@@ -30,7 +30,7 @@ main () ...@@ -30,7 +30,7 @@ main ()
{ {
return 0; return 0;
} }
catch (bad_exception) catch (std::bad_exception)
{ {
return 4; return 4;
} }
......
...@@ -8,15 +8,15 @@ void my_term () { exit (1); } ...@@ -8,15 +8,15 @@ void my_term () { exit (1); }
void my_unexp () { throw 42; } void my_unexp () { throw 42; }
void void
f () throw (bad_exception) f () throw (std::bad_exception)
{ {
throw 'a'; throw 'a';
} }
main () main ()
{ {
set_terminate (my_term); std::set_terminate (my_term);
set_unexpected (my_unexp); std::set_unexpected (my_unexp);
try try
{ {
...@@ -30,7 +30,7 @@ main () ...@@ -30,7 +30,7 @@ main ()
{ {
return 3; return 3;
} }
catch (bad_exception) catch (std::bad_exception)
{ {
return 0; return 0;
} }
......
...@@ -15,8 +15,8 @@ f () throw (short) ...@@ -15,8 +15,8 @@ f () throw (short)
main () main ()
{ {
set_terminate (my_term); std::set_terminate (my_term);
set_unexpected (my_unexp); std::set_unexpected (my_unexp);
try try
{ {
...@@ -30,7 +30,7 @@ main () ...@@ -30,7 +30,7 @@ main ()
{ {
return 3; return 3;
} }
catch (bad_exception) catch (std::bad_exception)
{ {
return 4; return 4;
} }
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
#include <iostream.h> #include <iostream.h>
#include <vector> #include <vector>
using std::vector;
class Component { class Component {
int george; int george;
char mabel[128]; char mabel[128];
...@@ -34,5 +36,5 @@ main(int argc, char**argv) { ...@@ -34,5 +36,5 @@ main(int argc, char**argv) {
exit(0); exit(0);
} }
template class __malloc_alloc_template<0>; template class std::__malloc_alloc_template<0>;
template class __default_alloc_template<false, 0>; template class std::__default_alloc_template<false, 0>;
...@@ -5,7 +5,7 @@ struct foo { double f(int); }; ...@@ -5,7 +5,7 @@ struct foo { double f(int); };
main() { main() {
double f (int); double f (int);
const type_info &r = typeid (f); const std::type_info &r = typeid (f);
cout << typeid(f).name() << endl; cout << typeid(f).name() << endl;
cout << typeid(foo::f).name() << endl; cout << typeid(foo::f).name() << endl;
} }
...@@ -11,7 +11,7 @@ int FLAG=0; ...@@ -11,7 +11,7 @@ int FLAG=0;
extern "C" int printf( const char *, ...); extern "C" int printf( const char *, ...);
void * operator new(size_t, const nothrow_t&) throw() { FLAG=1; return 0; } void * operator new(size_t, const std::nothrow_t&) throw() { FLAG=1; return 0; }
class K { class K {
private: private:
...@@ -24,7 +24,7 @@ public: ...@@ -24,7 +24,7 @@ public:
int main(void) int main(void)
{ {
K * pK = new (nothrow) K( 10); K * pK = new (std::nothrow) K( 10);
if ( FLAG != 1 ) if ( FLAG != 1 )
printf ("FAIL\n"); printf ("FAIL\n");
else else
......
...@@ -15,7 +15,7 @@ main() { ...@@ -15,7 +15,7 @@ main() {
B b; B b;
try { try {
(void)dynamic_cast<D&>(b); (void)dynamic_cast<D&>(b);
} catch (bad_cast) { } catch (std::bad_cast) {
return 0; return 0;
} }
return 1; return 1;
......
...@@ -18,7 +18,7 @@ main() { ...@@ -18,7 +18,7 @@ main() {
try { try {
void *vp = &dynamic_cast<D&>(*b); void *vp = &dynamic_cast<D&>(*b);
return 1; return 1;
} catch (bad_cast) { } catch (std::bad_cast) {
return 0; return 0;
} }
return 1; return 1;
......
...@@ -21,7 +21,7 @@ int main() { ...@@ -21,7 +21,7 @@ int main() {
try { try {
B b; B b;
x (b); x (b);
} catch (exception& e) { } catch (std::exception& e) {
// If we get a bad_cast, it is wrong. // If we get a bad_cast, it is wrong.
return 1; return 1;
} }
......
...@@ -36,7 +36,7 @@ void my_terminate() { ...@@ -36,7 +36,7 @@ void my_terminate() {
} }
main() { main() {
set_terminate (my_terminate); std::set_terminate (my_terminate);
try { try {
bar(); bar();
} catch (...) { } catch (...) {
......
...@@ -10,7 +10,7 @@ void my_terminate() { ...@@ -10,7 +10,7 @@ void my_terminate() {
struct A { struct A {
A() { } A() { }
~A() { ~A() {
set_terminate (my_terminate); std::set_terminate (my_terminate);
throw 1; // This throws from EH dtor, should call my_terminate throw 1; // This throws from EH dtor, should call my_terminate
} }
}; };
......
...@@ -10,7 +10,7 @@ void my_unexpected() { ...@@ -10,7 +10,7 @@ void my_unexpected() {
foo() throw (int) { throw "Hi"; } foo() throw (int) { throw "Hi"; }
main() { main() {
set_unexpected (my_unexpected); std::set_unexpected (my_unexpected);
try { try {
foo(); foo();
} catch (int i) { } catch (int i) {
......
...@@ -10,7 +10,7 @@ void my_unexpected() { ...@@ -10,7 +10,7 @@ void my_unexpected() {
foo() throw () { throw "Hi"; } foo() throw () { throw "Hi"; }
main() { main() {
set_unexpected (my_unexpected); std::set_unexpected (my_unexpected);
foo(); foo();
return 1; return 1;
} }
...@@ -14,7 +14,7 @@ main() { ...@@ -14,7 +14,7 @@ main() {
} catch (...) { } catch (...) {
} }
try { try {
set_terminate (myterm); std::set_terminate (myterm);
throw; throw;
} catch (...) { } catch (...) {
return 1; return 1;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// excess errors test - XFAIL a29k-*-* sparc64-*-elf sh-*-* arm-*-pe**-* // excess errors test - XFAIL a29k-*-* sparc64-*-elf sh-*-* arm-*-pe**-*
#include <exception> #include <exception>
using std::uncaught_exception;
class A { class A {
public: public:
~A() { ~A() {
......
...@@ -10,7 +10,7 @@ void my_unexpected() { ...@@ -10,7 +10,7 @@ void my_unexpected() {
template <class T> int foo(T) throw (int) { throw "Hi"; } template <class T> int foo(T) throw (int) { throw "Hi"; }
main() { main() {
set_unexpected (my_unexpected); std::set_unexpected (my_unexpected);
try { try {
foo(1); foo(1);
} catch (int i) { } catch (int i) {
......
...@@ -10,7 +10,7 @@ void my_unexpected() { ...@@ -10,7 +10,7 @@ void my_unexpected() {
template <class T> int foo(T) throw (T) { throw "Hi"; } template <class T> int foo(T) throw (T) { throw "Hi"; }
main() { main() {
set_unexpected (my_unexpected); std::set_unexpected (my_unexpected);
try { try {
foo(1); foo(1);
} catch (int i) { } catch (int i) {
......
...@@ -12,7 +12,7 @@ void throw_an_unexpected_exception() throw() { ...@@ -12,7 +12,7 @@ void throw_an_unexpected_exception() throw() {
} }
int main() { int main() {
set_terminate(my_terminate_handler); std::set_terminate(my_terminate_handler);
throw_an_unexpected_exception(); throw_an_unexpected_exception();
return 1; return 1;
} }
// excess errors test - XFAIL *-*-*
class Foo { class Foo {
}; };
......
// Build don't link: // Build don't link:
// excess errors test - XFAIL *-*-*
namespace N { namespace N {
struct C { struct C {
......
// Build don't link: // Build don't link:
// excess errors test - XFAIL *-*-*
namespace Jazz { namespace Jazz {
int horn( int h ) { return 1; } int horn( int h ) { return 1; }
......
// excess errors test - XFAIL *-*-*
namespace Foo { namespace Foo {
bar() { bar() {
return 0; return 0;
......
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);
}
// Build don't link:
class ostream;
extern ostream cout;
namespace foo
{
struct S
{
int i;
};
extern ostream &operator<<(ostream &, const S &);
}
void bar(foo::S s)
{
cout << s ;
}
// Build don't link:
typedef int __quad_t;
typedef __quad_t __qaddr_t;
// Build don't link:
template <class charT>
struct basic_string
{
charT append (charT c)
{ return c; }
};
typedef char c;
template class basic_string <char>;
namespace foo{
int eine_funktion(int)
{
return 0;
}
int eine_funktion(int,int)
{
return 1;
}
}
main(int,char**)
{
return foo::eine_funktion(1);
}
//Build don't link:
namespace bb
{
int f(int);
namespace k
{
void foo(int bar)
{
int i=bb:f(bar); // ERROR - namespace
}
}
}
// Build don't link
// Check [namespace.memdef]/2
namespace A{
void f(int);
void f(int,int);
int i; // ERROR - .*
}
void A::f(){} // ERROR - should have been declared before
namespace B{
void A::f(int){} // ERROR - B does not surround A
}
int A::i; // ERROR - redefinition
void A::f(int,int){} // ok
namespace fred
{
int barney();
extern int wilma;
}
int fred::barney()
{
return fred::wilma;
}
int fred::wilma;
int barney()
{
return 1;
}
main()
{
return fred::barney();
}
namespace foo{
struct X{
int i;
void f();
static int k1,k2;
};
void X::f(){}
int var;
int X::k1;
}
using namespace foo;
X zzz;
int X::k2;
void andere_funktion()
{
zzz.f();
var=4;
}
main(int,char**)
{
andere_funktion();
return 0;
}
// Build don't link:
namespace foo{
void eine_funktion(int)
{}
}
using namespace foo;
namespace foo{
void eine_funktion(int,int)
{}
}
void andere_funktion()
{
eine_funktion(3,4);
}
// Build don't link:
namespace A{
enum foo{a,b,c};
}
using A::foo;
using A::b;
void g()
{
foo x;
x=b;
}
// Build don't link:
namespace X{
class Y{};
}
X::Y z;
namespace A{
int i;
namespace B{
void f(){i++;}
int i;
void g(){i++;}
}
}
main()
{
return A::i-A::B::i;
}
// Build don't link:
namespace A{
struct X{
int i;
X(){}
X(int j);
void operator=(const X&);
virtual ~X(){}
};
void X::operator=(const X&o)
{
i=o.i;
}
}
A::X::X(int j):i(j){}
namespace A{
struct Y:public X{
int j;
Y(int,int);
};
}
A::Y::Y(int a,int b):X(a),j(b)
{}
// Build don't link:
namespace B{
void f();
}
using namespace B;
void g()
{
::f();
}
// Build don't link:
namespace bb
{
int f(int);
namespace k
{
void foo(int bar)
{
return bb:f(bar); //ERROR - syntax error
}
}
}
// Unqualified lookup should find all functions.
// Duplicates are ignored as long as they lose during overload resolution.
namespace A{
int f(){
return 1;
}
int f(double);
}
namespace B{
int f(int){
return 2;
}
int f(double);
}
int f(int,int)
{
return 3;
}
using namespace A;
using namespace B;
main()
{
if(f() != 1)
return 1;
if(f(1) != 2)
return 1;
if(f(0,0) != 3)
return 1;
return 0;
}
namespace A{
void f(); // ERROR - .*
}
using namespace A;
void f(); // ERROR - .*
void g()
{
f(); // ERROR - ambiguous, ::f or A::f ?
}
// Build don't link:
// Declarations after the first one don't affect the set of used decls.
namespace A{
void f(); // ERROR - .*
}
using A::f;
namespace A{
void f(int);
}
using A::f;
void g()
{
f(4); // ERROR - too many arguments
}
// Build don't link:
namespace A{
void f(); // ERROR - .*
}
using A::f;
void f(); // ERROR - duplicate declaration
// Build don't link:
namespace A{
void f(){} // ERROR - previous declaration
}
using A::f;
void f(int);
void f(){} // ERROR - conflict
void g()
{
f(4);
}
// Build don't link:
namespace foo {
template <class T>
class x {};
}
foo::x<int> y;
//Build don't link:
//Inheritance from templates which are namespace members
namespace foo {
template <class T>
struct x {
x(){}
};
}
class y : public foo::x<int> {};
y r;
// Build don't link:
using namespace bb; // ERROR - .*
// Build don't link:
void f();
namespace A{
using ::f;
}
extern "C" int printf(char*, ...);
int c, d;
class Foo
{
public:
Foo() { printf("Foo() 0x%08lx\n", (unsigned long)this); ++c; }
Foo(Foo const &) { printf("Foo(Foo const &) 0x%08lx\n", (unsigned long)this); }
~Foo() { printf("~Foo() 0x%08lx\n", (unsigned long)this); ++d; }
};
// Bar creates constructs a temporary Foo() as a default
class Bar
{
public:
Bar(Foo const & = Foo()) { printf("Bar(Foo const &) 0x%08lx\n", (unsigned long)this); }
};
void fakeRef(Bar *)
{
}
int main()
{
// Create array of Bar. Will use default argument on constructor.
// The old compiler will loop constructing Bar. Each loop will
// construct a temporary Foo() but will not destruct the Foo().
// The Foo() temporary is destructed only once after the loop
// completes. This could lead to a memory leak if the constructor
// of Foo() allocates memory.
Bar bar[2];
fakeRef(bar);
printf("Done\n");
if (c == d && c == 2)
return 0;
return 1;
}
// Build don't link:
template<class X, class Z>
class foo
{
public:
typedef X y;
class bar {
public:
void blah () { y Y; }
};
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment