Browse Source

Fix C4273 warnings about inconsistent dll linkage (#1491)

pull/1493/head
josetr 5 years ago committed by GitHub
parent
commit
bc8fb5caeb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      tests/CLI/CLI.cpp
  2. 2
      tests/CLI/CLI.h
  3. 90
      tests/Common/Common.cpp
  4. 83
      tests/Common/Common.h

2
tests/CLI/CLI.cpp

@ -5,6 +5,8 @@ int Types::AttributedSum(int A, int B)
return A + B; return A + B;
} }
TestProtectedDestructors::~TestProtectedDestructors() {}
std::string Date::testStdString(std::string s) std::string Date::testStdString(std::string s)
{ {
return s + "_test"; return s + "_test";

2
tests/CLI/CLI.h

@ -32,8 +32,6 @@ class DLL_API TestProtectedDestructors
~TestProtectedDestructors(); ~TestProtectedDestructors();
}; };
TestProtectedDestructors::~TestProtectedDestructors() {}
// Tests the insertion operator (<<) to ToString method pass // Tests the insertion operator (<<) to ToString method pass
class DLL_API Date class DLL_API Date
{ {

90
tests/Common/Common.cpp

@ -358,6 +358,10 @@ Bar indirectReturn()
return Bar(); return Bar();
} }
TestDelegates::TestDelegates() : A(Double), B(Double), C(&TestDelegates::Triple)
{
}
int TestDelegates::Double(int N) int TestDelegates::Double(int N)
{ {
return N * 2; return N * 2;
@ -449,6 +453,10 @@ int operator *(TestMoveOperatorToClass klass, int b)
return klass.A * b; return klass.A * b;
} }
TestMoveOperatorToClass::TestMoveOperatorToClass()
{
}
TestMoveOperatorToClass operator-(const TestMoveOperatorToClass& b) TestMoveOperatorToClass operator-(const TestMoveOperatorToClass& b)
{ {
TestMoveOperatorToClass nb; TestMoveOperatorToClass nb;
@ -835,6 +843,32 @@ void HasOverridenSetter::setVirtualGetter(int value)
{ {
} }
TestIndexedProperties::TestIndexedProperties() : p(1), f()
{
}
foo_t& TestIndexedProperties::operator[](int i) { return p; }
const TestProperties& TestIndexedProperties::operator[](short b) { return f; }
foo_t TestIndexedProperties::operator[](const char* name) { return p; }
foo_t* TestIndexedProperties::operator[](float f) { return &p; }
TestProperties* TestIndexedProperties::operator[](unsigned char b) { return &f; }
Bar& TestIndexedProperties::operator[](unsigned long i)
{
return bar;
}
Bar& TestIndexedProperties::operator[](const TypeMappedIndex& key)
{
return bar;
}
const foo_t& TestIndexedProperties::operator[](double f) { return p; }
foo_t TestIndexedProperties::operator[](TestProperties b) { return p; }
int TestIndexedProperties::operator[](CS_OUT char key)
{
return key;
}
TypeMappedIndex::TypeMappedIndex() TypeMappedIndex::TypeMappedIndex()
{ {
} }
@ -855,6 +889,12 @@ TestWideStrings::TestWideStrings()
{ {
} }
LPCWSTR TestWideStrings::GetWidePointer() { return L"Hello"; }
LPCWSTR TestWideStrings::GetWideNullPointer() { return 0; }
TestFixedArrays::TestFixedArrays() {}
InternalCtorAmbiguity::InternalCtorAmbiguity(void* param) InternalCtorAmbiguity::InternalCtorAmbiguity(void* param)
{ {
// cause a crash to indicate this is the incorrect ctor to invoke // cause a crash to indicate this is the incorrect ctor to invoke
@ -1166,11 +1206,27 @@ void sMallFollowedByCapital()
{ {
} }
TestNotStaticClass::TestNotStaticClass()
{
}
TestNotStaticClass TestNotStaticClass::StaticFunction()
{
return TestNotStaticClass();
}
int TestStaticClass::Add(int a, int b) { return a + b; }
int TestStaticClass::GetOneTwoThree() { return 123; }
int TestStaticClass::_Mult(int a, int b) { return a * b; }
int TestStaticClass::GetFourFiveSix() { return 456; }
TestStaticClass& TestStaticClass::operator=(const TestStaticClass& oth) TestStaticClass& TestStaticClass::operator=(const TestStaticClass& oth)
{ {
return *this; return *this;
} }
int TestStaticClassDerived::Foo() { return 0; }
HasCopyAndMoveConstructor::HasCopyAndMoveConstructor(int value) HasCopyAndMoveConstructor::HasCopyAndMoveConstructor(int value)
{ {
field = value; field = value;
@ -1358,6 +1414,9 @@ TestGetterSetterToProperties::TestGetterSetterToProperties()
{ {
} }
int TestGetterSetterToProperties::getWidth() { return 640; }
int TestGetterSetterToProperties::getHeight() { return 480; }
PointerToTypedefPointerTest::PointerToTypedefPointerTest() PointerToTypedefPointerTest::PointerToTypedefPointerTest()
{ {
} }
@ -1371,3 +1430,34 @@ void DLL_API PointerToPrimitiveTypedefPointerTestMethod(LPINT lp, int valToSet)
{ {
*lp = valToSet; *lp = valToSet;
} }
TestArraysPointers::TestArraysPointers(MyEnum* values, int count)
{
if (values && count) Value = values[0];
}
TestCopyConstructorRef::TestCopyConstructorRef()
{
}
TestCopyConstructorRef::TestCopyConstructorRef(const TestCopyConstructorRef& other)
{
A = other.A;
B = other.B;
}
SomeStruct::SomeStruct() : p(1) {}
ClassWithOverloadedOperators::ClassWithOverloadedOperators() {
}
ClassWithOverloadedOperators::ClassWithOverloadedOperators::operator char() { return 1; }
ClassWithOverloadedOperators::operator int() { return 2; }
ClassWithOverloadedOperators::operator short() { return 3; }
bool ClassWithOverloadedOperators::operator<(const ClassWithOverloadedOperators& other) const {
return true;
}
int TestIndexedPropertiesInValueType::operator[](int i) { return i; }

83
tests/Common/Common.h

@ -344,8 +344,6 @@ struct DLL_API TestMoveOperatorToClass
int B; int B;
}; };
TestMoveOperatorToClass::TestMoveOperatorToClass() {}
DLL_API int operator *(TestMoveOperatorToClass klass, int b); DLL_API int operator *(TestMoveOperatorToClass klass, int b);
DLL_API TestMoveOperatorToClass operator-(const TestMoveOperatorToClass& b); DLL_API TestMoveOperatorToClass operator-(const TestMoveOperatorToClass& b);
@ -392,10 +390,6 @@ struct DLL_API TestDelegates
MemberDelegate C; MemberDelegate C;
}; };
TestDelegates::TestDelegates() : A(Double), B(Double), C(&TestDelegates::Triple)
{
}
namespace DelegateNamespace namespace DelegateNamespace
{ {
namespace Nested namespace Nested
@ -437,14 +431,6 @@ private:
TestStaticClass(); TestStaticClass();
}; };
int TestStaticClass::Add(int a, int b) { return a + b; }
int TestStaticClass::GetOneTwoThree() { return 123; }
int TestStaticClass::_Mult(int a, int b) { return a * b; }
int TestStaticClass::GetFourFiveSix() { return 456; }
struct DLL_API TestStaticClassDerived : TestStaticClass struct DLL_API TestStaticClassDerived : TestStaticClass
{ {
static int Foo(); static int Foo();
@ -453,8 +439,6 @@ private:
TestStaticClassDerived(); TestStaticClassDerived();
}; };
int TestStaticClassDerived::Foo() { return 0; }
class DLL_API TestNotStaticClass class DLL_API TestNotStaticClass
{ {
public: public:
@ -463,15 +447,6 @@ private:
TestNotStaticClass(); TestNotStaticClass();
}; };
TestNotStaticClass::TestNotStaticClass()
{
}
TestNotStaticClass TestNotStaticClass::StaticFunction()
{
return TestNotStaticClass();
}
class HasIgnoredField class HasIgnoredField
{ {
Base<Derived> fieldOfIgnoredType; Base<Derived> fieldOfIgnoredType;
@ -498,16 +473,6 @@ public:
float B; float B;
}; };
TestCopyConstructorRef::TestCopyConstructorRef()
{
}
TestCopyConstructorRef::TestCopyConstructorRef(const TestCopyConstructorRef& other)
{
A = other.A;
B = other.B;
}
template <class T> template <class T>
struct EmptyNamedNestedEnum struct EmptyNamedNestedEnum
{ {
@ -521,8 +486,6 @@ typedef struct DLL_API SomeStruct
foo_t p; foo_t p;
} SomeStruct; } SomeStruct;
SomeStruct::SomeStruct() : p(1) {}
class DLL_API SomeClassExtendingTheStruct : public SomeStruct class DLL_API SomeClassExtendingTheStruct : public SomeStruct
{ {
}; };
@ -550,15 +513,6 @@ public:
virtual bool operator<(const ClassWithOverloadedOperators &other) const; virtual bool operator<(const ClassWithOverloadedOperators &other) const;
}; };
ClassWithOverloadedOperators::ClassWithOverloadedOperators() {}
ClassWithOverloadedOperators::operator char() { return 1; }
ClassWithOverloadedOperators::operator int() { return 2; }
ClassWithOverloadedOperators::operator short() { return 3; }
bool ClassWithOverloadedOperators::
operator<(const ClassWithOverloadedOperators &other) const {
return true;
}
// Tests global static function generation // Tests global static function generation
DLL_API int Function(); DLL_API int Function();
@ -696,36 +650,12 @@ private:
Bar bar; Bar bar;
}; };
TestIndexedProperties::TestIndexedProperties() : p(1), f() {}
foo_t& TestIndexedProperties::operator[](int i) { return p; }
foo_t TestIndexedProperties::operator[](const char* name) { return p; }
foo_t* TestIndexedProperties::operator[](float f) { return &p; }
const foo_t& TestIndexedProperties::operator[](double f) { return p; }
TestProperties* TestIndexedProperties::operator[](unsigned char b) { return &f; }
const TestProperties& TestIndexedProperties::operator[](short b) { return f; }
foo_t TestIndexedProperties::operator[](TestProperties b) { return p; }
Bar& TestIndexedProperties::operator[](unsigned long i)
{
return bar;
}
Bar& TestIndexedProperties::operator[](const TypeMappedIndex& key)
{
return bar;
}
int TestIndexedProperties::operator[](CS_OUT char key)
{
return key;
}
struct DLL_API TestIndexedPropertiesInValueType struct DLL_API TestIndexedPropertiesInValueType
{ {
public: public:
int operator[](int i); int operator[](int i);
}; };
int TestIndexedPropertiesInValueType::operator[](int i) { return i; }
// Tests variables // Tests variables
struct DLL_API TestVariables struct DLL_API TestVariables
{ {
@ -742,9 +672,6 @@ struct DLL_API TestWideStrings
LPCWSTR GetWideNullPointer(); LPCWSTR GetWideNullPointer();
}; };
LPCWSTR TestWideStrings::GetWidePointer() { return L"Hello"; }
LPCWSTR TestWideStrings::GetWideNullPointer() { return 0; }
enum struct MyEnum { A, B, C }; enum struct MyEnum { A, B, C };
typedef void (*VoidPtrRetFunctionTypedef) (); typedef void (*VoidPtrRetFunctionTypedef) ();
@ -761,8 +688,6 @@ public:
int ZeroSizedArray[0]; int ZeroSizedArray[0];
}; };
TestFixedArrays::TestFixedArrays() {}
class DLL_API TestArraysPointers class DLL_API TestArraysPointers
{ {
public: public:
@ -771,11 +696,6 @@ public:
MyEnum Value; MyEnum Value;
}; };
TestArraysPointers::TestArraysPointers(MyEnum *values, int count)
{
if (values && count) Value = values[0];
}
class DLL_API NonPrimitiveType class DLL_API NonPrimitiveType
{ {
public: public:
@ -799,9 +719,6 @@ struct DLL_API TestGetterSetterToProperties
int getHeight(); int getHeight();
}; };
int TestGetterSetterToProperties::getWidth() { return 640; }
int TestGetterSetterToProperties::getHeight() { return 480; }
// Tests conversion operators of classes // Tests conversion operators of classes
class DLL_API ClassA class DLL_API ClassA
{ {

Loading…
Cancel
Save