[cfe-commits] r56708 - /cfe/trunk/lib/AST/DeclGroup.cpp
Mike Stump
mrs at apple.com
Fri Sep 26 19:51:30 PDT 2008
On Sep 26, 2008, at 4:19 PM, Ted Kremenek wrote:
> Use a union instead of a bunch of magic casts to implement a
> variant. This removes the type-punning errors for DeclGroup.
This isn't safe either.
unions are a gcc extension not sanctions by the language standard and
they _only_ work when you have u.field1 and u.field2 in the source
code. The problem is you store as a Decl:
explicit DeclGroupRef(Decl* d) : D(d) {}
then, you fetch Raw:
Kind getKind() const { return (Kind) (Raw & Mask); }
when you call begin:
iterator begin() {
if (getKind() == DeclKind) return Raw ? &D : 0;
You have to fetch the same type you stored (or on of the other
loopholes previously mentioned).
More information about the cfe-commits
mailing list