Commit 1cf0dce8 by Danny Smith Committed by Danny Smith

PR c++/5287, PR c++/7910, PR c++/11021

	PR c++/5287, PR c++/7910,  PR c++/11021
	* testsuite/g++.dg/ext/dllimport1.C: Add mingw32 as target. Add
	tests for warnings.
	* testsuite/g++.dg/ext/dllimport2.C: Add tests for warnings.
	* testsuite/g++.dg/ext/dllimport3.C: Likewise.
	* testsuite/g++.dg/ext/dllimport4.C: New file.
	* testsuite/g++.dg/ext/dllimport5.C: New file.
	* testsuite/g++.dg/ext/dllimport6.C: New file.
	* testsuite/g++.dg/ext/dllimport7.C: New file.
	* testsuite/g++.dg/ext/dllimport8.C: New file.
	* testsuite/g++.dg/ext/dllimport9.C: New file.
	* testsuite/g++.dg/ext/dllimport10.C: New file.
	* testsuite/g++.dg/ext/dllexport1.C: New file.

From-SVN: r68917
parent 6b6cb52e
2003-07-04 Danny Smith <dannysmith@users.sourceforge.net>
PR c++/5287, PR c++/7910, PR c++/11021
* testsuite/g++.dg/ext/dllimport1.C: Add mingw32 as target. Add
tests for warnings.
* testsuite/g++.dg/ext/dllimport2.C: Add tests for warnings.
* testsuite/g++.dg/ext/dllimport3.C: Likewise.
* testsuite/g++.dg/ext/dllimport4.C: New file.
* testsuite/g++.dg/ext/dllimport5.C: New file.
* testsuite/g++.dg/ext/dllimport6.C: New file.
* testsuite/g++.dg/ext/dllimport7.C: New file.
* testsuite/g++.dg/ext/dllimport8.C: New file.
* testsuite/g++.dg/ext/dllimport9.C: New file.
* testsuite/g++.dg/ext/dllimport10.C: New file.
* testsuite/g++.dg/ext/dllexport1.C: New file.
2003-07-03 Mark Mitchell <mark@codesourcery.com> 2003-07-03 Mark Mitchell <mark@codesourcery.com>
* g++.old-deja/g++.jason/typeid1.C: Add dg-error marker. * g++.old-deja/g++.jason/typeid1.C: Add dg-error marker.
......
// Test that inline functions are exported with -fkeep-inline-functions.
// { dg-do compile { target i?86-*-cygwin* i?86-*-mingw*} }
// { dg-options -fkeep-inline-functions }
__attribute__((dllexport)) inline int foo (int a) { return a;}
class __attribute__((dllexport)) Bar
{
public:
Bar(){};
int inline_bar(int a) {return a;}
int outline_bar(int a);
};
int Bar::outline_bar(int a) {return foo (a);}
Bar abar;
// { dg-final { scan-assembler "\.section\[ \t\]*.drectve\n.*_ZN3Bar11outline_barEi" } }
// { dg-final { scan-assembler " -export:_ZN3Bar10inline_barEi" } }
// { dg-final { scan-assembler " -export:_Z3fooi" } }
// { dg-do compile { target i?86-*-cygwin* } } // PR c++/7910
// { dg-do compile { target i?86-*-cygwin* i?86-*-mingw*} }
// { dg-options { -Wall -W } }
class __attribute__((dllimport)) Foo class __attribute__((dllimport)) Foo
{ {
public: public:
virtual void dummy_foo_func(void) virtual void dummy_foo_func(void)
{} {} // { dg-warning "inline function" }
void Foo::dummy_foo_fun2();
virtual ~Foo(); // avoid warning
}; };
void Foo::dummy_foo_fun2()
{ // { dg-warning "defined" }
}
class Bar : public Foo class Bar : public Foo
{ {
public: public:
...@@ -19,3 +27,5 @@ Bar::~Bar() ...@@ -19,3 +27,5 @@ Bar::~Bar()
void Bar::dummy_bar_func() void Bar::dummy_bar_func()
{} {}
// { dg-final { scan-assembler-not "__imp___ZN3Foo14dummy_foo_fun" } }
// PR c++/5287, c++/11021
// Inherit a virtual method from a dllimport'd base class.
// { dg-do compile { target i?86-*-cygwin* i?86-*-mingw*} }
struct __attribute__((dllimport)) A
{
virtual void vfunc(void);
};
struct B : public A
{
};
B aB;
// { dg-do compile { target i?86-*-cygwin* i?86-*-mingw*} } // { dg-do compile { target i?86-*-cygwin* i?86-*-mingw*} }
// PR 9738 Dllimport attribute is overriden by later definition // PR c++/9738 Dllimport attribute is overriden by later definition/redeclaration
void __attribute__((dllimport)) Bar(void); void __attribute__((dllimport)) Bar(void);
void __attribute__((dllimport)) Baz(void);
__attribute__((dllimport)) int Biz;
__attribute__((dllimport)) int Boz;
void Foo(void)
{
Bar();
Baz();
Biz++;
Boz++;
}
void Foo(void) void Bar(void)
{ { // { dg-warning "defined" }
Bar(); }
}
void Baz(void); // { dg-warning "redeclared" }
void Bar(void) extern int Biz; // { dg-warning "redeclared" }
{ int Boz; // { dg-warning "defined" }
}
void foo()
{
Biz++;
}
...@@ -15,7 +15,7 @@ struct Foo ...@@ -15,7 +15,7 @@ struct Foo
void* dummy = &f; void* dummy = &f;
} }
struct Foo f; struct Foo f; // { dg-warning "defined" }
// Dllimport sets DECL_NON_ADDR_CONST_P to 1, so following // Dllimport sets DECL_NON_ADDR_CONST_P to 1, so following
// assignment would require static_initialization_and_destruction // assignment would require static_initialization_and_destruction
......
// Report error if dllimport attribute in definition itself.
// { dg-do compile { target i?86-*-cygwin* i?86-*-mingw*} }
__attribute__((dllimport)) void bar () { } // { dg-error "definition" }
__attribute__((dllimport)) int foo = 1; // { dg-error "definition" }
// { dg-do compile { target i?86-*-cygwin* i?86-*-mingw*} }
// Report error if static symbol definition has dllimport attribute.
__attribute__((dllimport))
int impvar; // OK, implicit "extern"
static __attribute__((dllimport))
int static_impvar; // { dg-error "external linkage" }
static __attribute__((dllexport))
int static_expvar; // { dg-error "external linkage" }
static __attribute__((dllimport))
void static_impfun(void); // { dg-error "external linkage" }
void foo()
{
__attribute__((dllimport))
int foovar; // OK, implicit "extern"
foovar++;
}
void bar()
{
__attribute__((dllexport))
int barvar; // { dg-error "external linkage" }
barvar++;
}
// { dg-do compile { target i?86-*-cygwin* i?86-*-mingw*} }
// Mark class static members as dllimport.
struct Baz
{
Baz(int a_ =0) : a(a_) {};
int a;
};
class __attribute__ ((dllimport)) Bar
{
public:
static const int two = 2;
static const int three;
static const Baz null_baz;
};
int foo()
{
Bar foobar;
const int* baz = &Bar::two;
int a = foobar.two;
int b = foobar.three;
int c = foobar.null_baz.a;
return (a + b + c + *baz);
}
// { dg-final { scan-assembler __imp___ZN3Bar3twoE } }
// { dg-final { scan-assembler __imp___ZN3Bar5threeE } }
// { dg-final { scan-assembler __imp___ZN3Bar8null_bazE } }
// { dg-do compile { target i?86-*-cygwin* i?86-*-mingw*} }
// Report errors on definition of dllimport'd static data member .
struct Baz
{
Baz(int a_ =0) : a(a_) {};
int a;
};
class __declspec(dllimport) Bar
{
public:
enum {one = 1};
static const int two = 2;
static const int three;
static const Baz null_baz;
};
const int Bar::three = 3; // { dg-error "definition of static data" }
const Baz Bar::null_baz; // { dg-error "definition of static data" }
int foo()
{
Bar foobar;
const int* baz = &Bar::two;
int a = foobar.two;
int b = foobar.three;
int c = foobar.null_baz.a;
return (a + b + c + *baz);
}
// PR c++/8378
// Ignore dllimport of static members if marked inlined.
// or if definition follows declaration in dllimported class.
// { dg-do compile { target i?86-*-cygwin* i?86-*-mingw*} }
// { dg-options { -Wall -W } }
struct __attribute__((dllimport)) Foo
{
static int static_int;
static void static_func1();
static void static_func2();
};
void Foo::static_func1()
{ // { dg-warning "defined" }
}
inline void Foo::static_func2()
{ // { dg-warning "inline function" }
}
void testfoo()
{
Foo::static_func1();
Foo::static_func2();
}
// { dg-final { scan-assembler-not "__imp__" } }
// Handle dllimport attribute for functions declared inline.
// { dg-do compile { target i?86-*-cygwin* i?86-*-mingw*} }
// { dg-options { -W } }
inline __attribute__((dllimport)) void bar() { } // { dg-warning "inline" }
struct __attribute__ ((dllimport)) Blah
{
void in_blah () { } // { dg-warning "inline" }
void out_blah ();
};
inline void Blah::out_blah(){ } // { dg-warning "inline" }
void use_inlines()
{
Blah aBlah;
bar();
aBlah.in_blah ();
aBlah.out_blah ();
}
// { dg-final { scan-assembler-not "__imp__" } }
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