-
- Downloads
d: Warn when declared size of a special enum does not match its intrinsic type.
All special enums have declarations in the D runtime library, but the compiler will recognize and treat them specially if declared in any module. When the underlying base type of a special enum is a different size to its matched intrinsic, then this can cause undefined behavior at runtime. Detect and warn about when such a mismatch occurs. gcc/d/ChangeLog: * gdc.texi (Warnings): Document -Wextra and -Wmismatched-special-enum. * implement-d.texi (Special Enums): Add reference to warning option -Wmismatched-special-enum. * lang.opt: Add -Wextra and -Wmismatched-special-enum. * types.cc (TypeVisitor::visit (TypeEnum *)): Warn when declared special enum size mismatches its intrinsic type. gcc/testsuite/ChangeLog: * gdc.dg/Wmismatched_enum.d: New test.
Showing
- gcc/d/gdc.texi 17 additions, 0 deletionsgcc/d/gdc.texi
- gcc/d/implement-d.texi 5 additions, 0 deletionsgcc/d/implement-d.texi
- gcc/d/lang.opt 8 additions, 0 deletionsgcc/d/lang.opt
- gcc/d/types.cc 15 additions, 0 deletionsgcc/d/types.cc
- gcc/testsuite/gdc.dg/Wmismatched_enum.d 4 additions, 0 deletionsgcc/testsuite/gdc.dg/Wmismatched_enum.d
Loading
Please register or sign in to comment