Files
swift-mirror/userdocs/diagnostics/diagnostic-groups.md
Allan Shortlidge dacd986f1b AST: Introduce a warning group for a versioned #if canImport diagnostic.
This allows developers to control whether these diagnostics are considered
errors when `-warnings-as-errors` is specified.

Resolves rdar://157694667.
2025-08-11 16:06:06 -07:00

1.3 KiB

Diagnostic groups

Diagnostic groups allow controlling the behavior of warnings in a more precise manner.

Overview

Diagnostic groups collect some number of diagnostics together under a common group name. This allows for extra documentation to help explain relevant language concepts, as well as the ability to control the behavior of warnings in a more precise manner:

  • -Werror <group> - upgrades warnings in the specified group to errors
  • -Wwarning <group> - indicates that warnings in the specified group should remain warnings, even if they were previously upgraded to errors

As a concrete example, to upgrade deprecated declaration warnings to errors:

-Werror DeprecatedDeclaration

Or upgrade all warnings except deprecated declaration to errors:

-warnings-as-errors -Wwarning DeprecatedDeclaration

Topics