[cfe-commits] Fix for the -mms-bitfields commandline parameter
Eli Friedman
eli.friedman at gmail.com
Mon Oct 8 16:18:47 PDT 2012
On Mon, Oct 8, 2012 at 2:47 PM, Jeremiah Zanin
<Jeremiah.Zanin at volition-inc.com> wrote:
> The "-mms-bitfields" commandline parameter now properly turns on the ms_struct behavior.
>
> I've never submitted a code change before, hopefully I did this correctly. I included the patch and a new test file.
>
> One result of this change is that __attribute__((ms_struct)) on an enum will produce a warning, for example:
>
> enum __attribute__((ms_struct)) bar {
> BAR_A = 0,
> BAR_B,
> BAR_C
> };
>
> ms-bitfields-test.cpp:4:21: warning: 'ms_struct' attribute ignored
> enum __attribute__((ms_struct)) bar {
>
> Is this desired?
Yes. Please include a testcase for that.
Please include testcases inside a patch (use "svn add").
This patch would be much simpler if you just implemented isMsStruct as:
bool RecordDecl::isMsStruct(ASTContext &Ctx) {
return RD->hasAttr<MsStructAttr>() ||
Ctx.getLangOpts().MSBitfields == 1;
}
(Also, your current patch doesn't properly handle serialization of
RecordDecls; no change is necessary if you don't add a new bit.)
+ if (RecordDecl *RD = dyn_cast<RecordDecl>(D)) {
+ RD->addAttr(::new (S.Context) MsStructAttr(Attr.getRange(), S.Context));
+ RD->setMsStruct(true);
+ }
else
S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();
We generally prefer brace on the same line as else.
-Eli
More information about the cfe-commits
mailing list