From 93d6fd95a8e265fad66b956502bdeb3f87a09c49 Mon Sep 17 00:00:00 2001 From: giovannibajo Date: Sun, 7 Dec 2003 15:26:05 +0000 Subject: [PATCH] * g++.dg/lookup/java1.C: New test. * g++.dg/lookup/java2.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@74395 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/testsuite/ChangeLog | 5 +++ gcc/testsuite/g++.dg/lookup/java1.C | 68 +++++++++++++++++++++++++++++++++++++ gcc/testsuite/g++.dg/lookup/java2.C | 47 +++++++++++++++++++++++++ 3 files changed, 120 insertions(+) create mode 100644 gcc/testsuite/g++.dg/lookup/java1.C create mode 100644 gcc/testsuite/g++.dg/lookup/java2.C diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 558f7a4..09784c0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2003-12-07 Giovanni Bajo + + * g++.dg/lookup/java1.C: New test. + * g++.dg/lookup/java2.C: New test. + 2003-12-07 Falk Hueffner * g++.dg/opt/noreturn-1.C: New test. diff --git a/gcc/testsuite/g++.dg/lookup/java1.C b/gcc/testsuite/g++.dg/lookup/java1.C new file mode 100644 index 0000000..550ff59 --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/java1.C @@ -0,0 +1,68 @@ +// { dg-do compile } +// { dg-options "" } +// Origin: Giovanni Bajo +// Make sure that Java special functions can be called correctly. + +extern "Java" +{ + typedef __java_int jint; + namespace java + { + namespace lang + { + class Class; + class Object; + class Throwable {}; + class Foo; + } + } +} + +typedef struct java::lang::Object* jobject; +typedef struct java::lang::Throwable* jthrowable; +typedef class java::lang::Class* jclass; +using java::lang::Foo; + +class Foo : public java::lang::Throwable +{ +public: + static ::java::lang::Class class$; +}; + + +/* + * Step 1: no declarations. A declaration for _Jv_Throw is created. + */ + +void Bar1(void) +{ + Foo* f = new java::lang::Foo; // { dg-error "call to Java constructor" } + throw (f); +} + + +/* + * Step 2: constructor declaration + */ + +extern "C" jobject _Jv_AllocObject (jclass, jint) __attribute__((__malloc__)); + +void Bar2(void) +{ + Foo* f = new java::lang::Foo; + throw (f); +} + + +/* + * Step 3: overloads + */ + +jobject _Jv_AllocObject (jclass, jint, float) __attribute__((__malloc__)); +void _Jv_Throw (int, float) __attribute__ ((__noreturn__)); + +void Bar3(void) +{ + Foo* f = new java::lang::Foo; // { dg-error "should never be overloaded" } + throw (f); // { dg-error "should never be overloaded" } +} diff --git a/gcc/testsuite/g++.dg/lookup/java2.C b/gcc/testsuite/g++.dg/lookup/java2.C new file mode 100644 index 0000000..6c78715 --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/java2.C @@ -0,0 +1,47 @@ +// { dg-do compile } +// { dg-options "" } +// Origin: Giovanni Bajo +// Make sure that Java special functions can be called correctly. +// (continue from java1.C) + +extern "Java" +{ + typedef __java_int jint; + namespace java + { + namespace lang + { + class Class; + class Object; + class Throwable {}; + class Foo; + } + } +} + +typedef struct java::lang::Object* jobject; +typedef struct java::lang::Throwable* jthrowable; +typedef class java::lang::Class* jclass; +using java::lang::Foo; + +class Foo : public java::lang::Throwable +{ +public: + static ::java::lang::Class class$; +}; + +/* + * Step 4: Manual declaration of _Jv_Throw + * This is the last case we need to test. In the other file we're testing + * the compiler is able to generate an artifical declaration for this + * function, so we need to test here if it works with a normal declaration. + */ + +extern "C" jobject _Jv_AllocObject (jclass, jint) __attribute__((__malloc__)); +extern "C" void _Jv_Throw (jthrowable) __attribute__ ((__noreturn__)); + +void Bar4(void) +{ + Foo* f = new java::lang::Foo; + throw (f); +} -- 2.7.4