diff --git a/src/CppParser/Parser.cpp b/src/CppParser/Parser.cpp index e246d7a3..2fdae315 100644 --- a/src/CppParser/Parser.cpp +++ b/src/CppParser/Parser.cpp @@ -386,6 +386,8 @@ void Parser::SetupHeader() case llvm::Triple::Linux: TC = new clang::driver::toolchains::Linux(D, Target, Args); break; + default: + break; } if (TC && !Opts->NoStandardIncludes) { @@ -2738,6 +2740,8 @@ static clang::TypeLoc DesugarTypeLoc(const clang::TypeLoc& Loc) auto PTL = Loc.getAs(); return PTL.getInnerLoc(); } + default: + break; } return Loc; @@ -3546,7 +3550,7 @@ Declaration* Parser::WalkDeclaration(const clang::Decl* D, Typedef->QualifiedType = GetQualifiedType(TD->getUnderlyingType(), &TTL); AST::TypedefDecl* Existing; // if the typedef was added along the way, the just created one is useless, delete it - if (Existing = NS->FindTypedef(Name, /*Create=*/false)) + if ((Existing = NS->FindTypedef(Name, /*Create=*/false))) delete Typedef; else NS->Typedefs.push_back(Existing = Typedef); @@ -3570,7 +3574,7 @@ Declaration* Parser::WalkDeclaration(const clang::Decl* D, // see above the case for "Typedef" TypeAlias->QualifiedType = GetQualifiedType(TD->getUnderlyingType(), &TTL); AST::TypeAlias* Existing; - if (Existing = NS->FindTypeAlias(Name, /*Create=*/false)) + if ((Existing = NS->FindTypeAlias(Name, /*Create=*/false))) delete TypeAlias; else NS->TypeAliases.push_back(Existing = TypeAlias); diff --git a/tests/CSharp/CSharp.Tests.cs b/tests/CSharp/CSharp.Tests.cs index fa949419..c8b96fbb 100644 --- a/tests/CSharp/CSharp.Tests.cs +++ b/tests/CSharp/CSharp.Tests.cs @@ -19,6 +19,9 @@ public unsafe class CSharpTests : GeneratorTestFixture [Test] public void TestUncompilableCode() { +#pragma warning disable 0168 // warning CS0168: The variable `foo' is declared but never used +#pragma warning disable 0219 // warning CS0219: The variable `foo' is assigned but its value is never used + ALLCAPS_UNDERSCORES a; using (var testRenaming = new TestRenaming()) { @@ -63,6 +66,9 @@ public unsafe class CSharpTests : GeneratorTestFixture { int i = typeMappedWithOperator | 5; } + +#pragma warning restore 0168 +#pragma warning restore 0219 } [Test] diff --git a/tests/CSharp/CSharp.cpp b/tests/CSharp/CSharp.cpp index ba58370c..b2171d94 100644 --- a/tests/CSharp/CSharp.cpp +++ b/tests/CSharp/CSharp.cpp @@ -1,6 +1,6 @@ #include "CSharp.h" -Foo::Foo(char* name) +Foo::Foo(const char* name) { A = 10; P = 50; @@ -264,7 +264,8 @@ long Proprietor::prop() const Baz& Proprietor::covariant() { - return Baz(); + static Baz baz; + return baz; } Bar::Items Proprietor::items() const @@ -459,7 +460,7 @@ MethodsWithDefaultValues::QMargins::QMargins(int left, int top, int right, int b { } -char* MethodsWithDefaultValues::stringConstant = "test"; +const char* MethodsWithDefaultValues::stringConstant = "test"; int MethodsWithDefaultValues::intConstant = 5; MethodsWithDefaultValues::MethodsWithDefaultValues(Foo foo) diff --git a/tests/CSharp/CSharp.h b/tests/CSharp/CSharp.h index 14dd4e12..d5ca900c 100644 --- a/tests/CSharp/CSharp.h +++ b/tests/CSharp/CSharp.h @@ -7,7 +7,7 @@ class DLL_API Foo { public: - Foo(char* name = 0); + Foo(const char* name = 0); Foo(int a, int p = 0); int method(); int operator[](int i) const; @@ -382,7 +382,7 @@ public: QMargins(int left, int top, int right, int bottom); }; - static char* stringConstant; + static const char* stringConstant; static int intConstant; MethodsWithDefaultValues(Foo foo = Foo()); diff --git a/tests/Common/Common.Tests.cs b/tests/Common/Common.Tests.cs index f03c94ce..99070551 100644 --- a/tests/Common/Common.Tests.cs +++ b/tests/Common/Common.Tests.cs @@ -10,6 +10,9 @@ public class CommonTests : GeneratorTestFixture [Test] public void TestCodeGeneration() { +#pragma warning disable 0168 // warning CS0168: The variable `foo' is declared but never used +#pragma warning disable 0219 // warning CS0219: The variable `foo' is assigned but its value is never used + Assert.That(new ChangedAccessOfInheritedProperty().property, Is.EqualTo(2)); Foo.NestedAbstract a; var renamedEmptyEnum = Foo.RenamedEmptyEnum.EmptyEnum1; @@ -31,6 +34,9 @@ public class CommonTests : GeneratorTestFixture using (var hasProtectedEnum = new HasProtectedEnum()) { } + +#pragma warning restore 0168 +#pragma warning restore 0219 } [Test] diff --git a/tests/Common/Common.h b/tests/Common/Common.h index 10594022..a7177f74 100644 --- a/tests/Common/Common.h +++ b/tests/Common/Common.h @@ -1079,7 +1079,7 @@ public: DerivedFromTemplateInstantiationWithVirtual(); }; -typedef DLL_API union +typedef union { int c; } union_t;