From 08b255868a50faeae359f272c8af0d16c0e4abf4 Mon Sep 17 00:00:00 2001 From: krsk Date: Wed, 14 Sep 2016 12:02:16 +0200 Subject: [PATCH 1/2] Push and pop GCC diagnostics to maintain scope for changed warning flags --- lib/cmock_generator.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/cmock_generator.rb b/lib/cmock_generator.rb index 7009ece..1414c4a 100644 --- a/lib/cmock_generator.rb +++ b/lib/cmock_generator.rb @@ -102,6 +102,7 @@ class CMockGenerator file << "\n" file << "/* Ignore the following warnings, since we are copying code */\n" file << "#if defined(__GNUC__) && !defined(__ICC) && !defined(__TMS470__)\n" + file << "#pragma GCC diagnostic push\n" file << "#if !defined(__clang__)\n" file << "#pragma GCC diagnostic ignored \"-Wpragmas\"\n" file << "#endif\n" @@ -124,7 +125,12 @@ class CMockGenerator end def create_mock_header_footer(header) - header << "\n#endif\n" + header << "\n" + header << "#if defined(__GNUC__) && !defined(__ICC) && !defined(__TMS470__)\n" + header << "#pragma GCC diagnostic pop\n" + header << "#endif\n" + header << "\n" + header << "#endif\n" end def create_source_header_section(file, filename, functions) From 1ffba4383c515f5baee960cd43ad02f7e5e9d716 Mon Sep 17 00:00:00 2001 From: Trond Einar Snekvik Date: Thu, 3 Aug 2017 10:08:22 +0200 Subject: [PATCH 2/2] Update test header and footer to match updated contents --- test/unit/cmock_generator_main_test.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/unit/cmock_generator_main_test.rb b/test/unit/cmock_generator_main_test.rb index 7b6b728..210825a 100644 --- a/test/unit/cmock_generator_main_test.rb +++ b/test/unit/cmock_generator_main_test.rb @@ -98,6 +98,7 @@ describe CMockGenerator, "Verify CMockGenerator Module" do "\n", "/* Ignore the following warnings, since we are copying code */\n", "#if defined(__GNUC__) && !defined(__ICC) && !defined(__TMS470__)\n", + "#pragma GCC diagnostic push\n", "#if !defined(__clang__)\n", "#pragma GCC diagnostic ignored \"-Wpragmas\"\n", "#endif\n", @@ -150,6 +151,7 @@ describe CMockGenerator, "Verify CMockGenerator Module" do "\n", "/* Ignore the following warnings, since we are copying code */\n", "#if defined(__GNUC__) && !defined(__ICC) && !defined(__TMS470__)\n", + "#pragma GCC diagnostic push\n", "#if !defined(__clang__)\n", "#pragma GCC diagnostic ignored \"-Wpragmas\"\n", "#endif\n", @@ -185,6 +187,7 @@ describe CMockGenerator, "Verify CMockGenerator Module" do "\n", "/* Ignore the following warnings, since we are copying code */\n", "#if defined(__GNUC__) && !defined(__ICC) && !defined(__TMS470__)\n", + "#pragma GCC diagnostic push\n", "#if !defined(__clang__)\n", "#pragma GCC diagnostic ignored \"-Wpragmas\"\n", "#endif\n", @@ -221,6 +224,7 @@ describe CMockGenerator, "Verify CMockGenerator Module" do "\n", "/* Ignore the following warnings, since we are copying code */\n", "#if defined(__GNUC__) && !defined(__ICC) && !defined(__TMS470__)\n", + "#pragma GCC diagnostic push\n", "#if !defined(__clang__)\n", "#pragma GCC diagnostic ignored \"-Wpragmas\"\n", "#endif\n", @@ -272,7 +276,13 @@ describe CMockGenerator, "Verify CMockGenerator Module" do it "append the proper footer to the header file" do output = [] - expected = ["\n#endif\n"] + expected = ["\n", + "#if defined(__GNUC__) && !defined(__ICC) && !defined(__TMS470__)\n", + "#pragma GCC diagnostic pop\n", + "#endif\n", + "\n", + "#endif\n" + ] @cmock_generator.create_mock_header_footer(output)