{"id":46048,"date":"2024-12-05T16:09:03","date_gmt":"2024-12-05T21:09:03","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=46048"},"modified":"2024-12-05T16:09:03","modified_gmt":"2024-12-05T21:09:03","slug":"swift-proposal-precise-control-flags-over-compiler-warnings","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2024\/12\/05\/swift-proposal-precise-control-flags-over-compiler-warnings\/","title":{"rendered":"Swift Proposal: Precise Control Flags Over Compiler Warnings"},"content":{"rendered":"<p><a href=\"https:\/\/github.com\/swiftlang\/swift-evolution\/blob\/main\/proposals\/0443-warning-control-flags.md\">SE-0443<\/a>:<\/p>\n<blockquote cite=\"https:\/\/github.com\/swiftlang\/swift-evolution\/blob\/main\/proposals\/0443-warning-control-flags.md\"><p>This proposal suggests adding new options that will allow the behavior of warnings to be controlled based on their diagnostic group.<\/p><ul><li><code>-Werror &lt;group&gt;<\/code> - upgrades warnings in the specified group to errors<\/li><li><code>-Wwarning &lt;group&gt;<\/code> - indicates that warnings in the specified group should remain warnings, even if they were previously suppressed or upgraded to errors<\/li><\/ul><p>[&#8230;]<\/p><p>Thus, for example, you can use the combination <code>-warnings-as-errors -Wwarning deprecated<\/code>, which will upgrade all warnings to errors except for those in the <code>deprecated<\/code> group. However, if these flags are specified in the reverse order(<code>-Wwarning deprecated -warnings-as-errors<\/code>) it will be interpreted as upgrading all warnings to errors, as the <code>-warnings-as-errors<\/code> flag is the last one.<\/p><p>[&#8230;]<\/p><p>We are also introducing a new compiler flag, <code>-print-diagnostic-groups<\/code>, to display the names of diagnostic groups along with the textual representation of the warnings.<\/p><\/blockquote>\n\n<p>I&rsquo;ve linked to this before, but I wanted to give it a full post because I think it&rsquo;s important. I&rsquo;d still like to see even more control over warnings, e.g. a way to suppress a particular warning or deprecation only within a certain region of code, as was possible with Clang.<\/p>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2024\/09\/20\/unwanted-swift-concurrency-checking\/\">Unwanted Swift Concurrency Checking<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2024\/06\/04\/swift-at-10\/\">Swift at 10<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2015\/05\/08\/clangs-new-wpartial-availability\/\">Clang&rsquo;s New -Wpartial-availability<\/a><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>SE-0443: This proposal suggests adding new options that will allow the behavior of warnings to be controlled based on their diagnostic group.-Werror &lt;group&gt; - upgrades warnings in the specified group to errors-Wwarning &lt;group&gt; - indicates that warnings in the specified group should remain warnings, even if they were previously suppressed or upgraded to errors[&#8230;]Thus, for [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2024-12-05T21:09:05Z","apple_news_api_id":"9b351949-c6f9-4938-b12d-58c6b410467e","apple_news_api_modified_at":"2024-12-05T21:09:05Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/AmzUZScb5STixLVjGtBBGfg","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[46,71,901],"class_list":["post-46048","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-languagedesign","tag-programming","tag-swift-programming-language"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/46048","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=46048"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/46048\/revisions"}],"predecessor-version":[{"id":46049,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/46048\/revisions\/46049"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=46048"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=46048"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=46048"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}