{"action":"created","issue":{"url":"https://api.github.com/repos/D-Programming-Language/dmd/issues/5592","repository_url":"https://api.github.com/repos/D-Programming-Language/dmd","labels_url":"https://api.github.com/repos/D-Programming-Language/dmd/issues/5592/labels{/name}","comments_url":"https://api.github.com/repos/D-Programming-Language/dmd/issues/5592/comments","events_url":"https://api.github.com/repos/D-Programming-Language/dmd/issues/5592/events","html_url":"https://github.com/D-Programming-Language/dmd/pull/5592","id":144007129,"number":5592,"title":"Add warning categories","user":{"login":"JohanEngelen","id":10983051,"avatar_url":"https://avatars.githubusercontent.com/u/10983051?v=3","gravatar_id":"","url":"https://api.github.com/users/JohanEngelen","html_url":"https://github.com/JohanEngelen","followers_url":"https://api.github.com/users/JohanEngelen/followers","following_url":"https://api.github.com/users/JohanEngelen/following{/other_user}","gists_url":"https://api.github.com/users/JohanEngelen/gists{/gist_id}","starred_url":"https://api.github.com/users/JohanEngelen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JohanEngelen/subscriptions","organizations_url":"https://api.github.com/users/JohanEngelen/orgs","repos_url":"https://api.github.com/users/JohanEngelen/repos","events_url":"https://api.github.com/users/JohanEngelen/events{/privacy}","received_events_url":"https://api.github.com/users/JohanEngelen/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/D-Programming-Language/dmd/labels/Enhancement","name":"Enhancement","color":"0052cc"},{"url":"https://api.github.com/repos/D-Programming-Language/dmd/labels/Needs%20Approval","name":"Needs Approval","color":"e11d21"}],"state":"open","locked":false,"assignee":{"login":"WalterBright","id":568298,"avatar_url":"https://avatars.githubusercontent.com/u/568298?v=3","gravatar_id":"","url":"https://api.github.com/users/WalterBright","html_url":"https://github.com/WalterBright","followers_url":"https://api.github.com/users/WalterBright/followers","following_url":"https://api.github.com/users/WalterBright/following{/other_user}","gists_url":"https://api.github.com/users/WalterBright/gists{/gist_id}","starred_url":"https://api.github.com/users/WalterBright/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WalterBright/subscriptions","organizations_url":"https://api.github.com/users/WalterBright/orgs","repos_url":"https://api.github.com/users/WalterBright/repos","events_url":"https://api.github.com/users/WalterBright/events{/privacy}","received_events_url":"https://api.github.com/users/WalterBright/received_events","type":"User","site_admin":false},"milestone":null,"comments":10,"created_at":"2016-03-28T15:41:26Z","updated_at":"2016-03-29T12:16:25Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/D-Programming-Language/dmd/pulls/5592","html_url":"https://github.com/D-Programming-Language/dmd/pull/5592","diff_url":"https://github.com/D-Programming-Language/dmd/pull/5592.diff","patch_url":"https://github.com/D-Programming-Language/dmd/pull/5592.patch"},"body":"This PR splits warnings into categories, which can then be disabled/enabled to suit the user. For example the \"statement not reachable\" warning is very hard/ugly to work around in generic code, which means the user cannot compile with warnings enabled (warning spam), nor with warnings=errors. With this PR, the user could do `dmd -w -Wno-not-reachable`, enabling all warnings except the not-reachable warning category.\r\nThe dlang.org Warning page says:\r\n\"Most have generated some spirited debate as to whether it should be a warning, an error, and what the correct way to write D code in these situations should be. Since no consensus emerged, they appear as optional warnings, with alternatives on how to write correct code.\"\r\nThis PR makes warnings *individually* optional.\r\n\r\nNew commandline options are added, all starting with capital W: `-W...`\r\nThe behavior of `-w` and `-wi` is unchanged.\r\n`-Werror` (warnings=errors, without enabling all warning categories)\r\n`-W...` and `Wno-...` where a category name must be inserted on the dots.\r\nThe category name is output at the end of the warning text (like clang does).\r\nA warning can be put into more than one category, although at the moment all warnings belong to a single category.\r\nLater options overwrite earlier options.\r\nExamples: \r\n`-w`, as before.\r\n`-wi -Werror` == `-w`\r\n`-wi -Wno-conversion`, will not warn on int += float\r\n`-Wconversion`, will *only* warn on int += float\r\n`-Wno-conversion -Wconversion`, will *only* warn on int += float\r\n`-Wconversion -Wno-conversion`, will not warn at all\r\n`-Werror -Wconversion`, will *only* warn on int += float and will error on that warning\r\n\r\nSome PR details:\r\n1.  move warning-related code from `errors.d` to the new file `warnings.d`\r\n2.  define a number of categories and assign each of the current warnings to a category (most are in their own category), implement category commandline arguments + filtering of the warnings, add category name (colored) to the warning output\r\n3.  add extra tests for warnings. In the process of adding warnings, I fixed a bug where post-semantic warnings did not result in an error with `-w` (notably, the previously untested `toHash()` warning).\r\n"},"comment":{"url":"https://api.github.com/repos/D-Programming-Language/dmd/issues/comments/202863605","html_url":"https://github.com/D-Programming-Language/dmd/pull/5592#issuecomment-202863605","issue_url":"https://api.github.com/repos/D-Programming-Language/dmd/issues/5592","id":202863605,"user":{"login":"JohanEngelen","id":10983051,"avatar_url":"https://avatars.githubusercontent.com/u/10983051?v=3","gravatar_id":"","url":"https://api.github.com/users/JohanEngelen","html_url":"https://github.com/JohanEngelen","followers_url":"https://api.github.com/users/JohanEngelen/followers","following_url":"https://api.github.com/users/JohanEngelen/following{/other_user}","gists_url":"https://api.github.com/users/JohanEngelen/gists{/gist_id}","starred_url":"https://api.github.com/users/JohanEngelen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JohanEngelen/subscriptions","organizations_url":"https://api.github.com/users/JohanEngelen/orgs","repos_url":"https://api.github.com/users/JohanEngelen/repos","events_url":"https://api.github.com/users/JohanEngelen/events{/privacy}","received_events_url":"https://api.github.com/users/JohanEngelen/received_events","type":"User","site_admin":false},"created_at":"2016-03-29T12:16:25Z","updated_at":"2016-03-29T12:16:25Z","body":"> Somebody has to document this stuff, explain it, determine best practice, etc.\r\n\r\nPretty much all warnings are not documented at the moment (yet they were added, and a few are not tested either)."}}