Skip to content
Snippets Groups Projects
Commit 3ad9313a authored by Iain Buclaw's avatar Iain Buclaw
Browse files

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.
parent 108ff03b
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment