Ok, here's the updated patch.

Jeremiah

-----Original Message-----
From: Eli Friedman [mailto:[email protected]]
Sent: Monday, October 08, 2012 6:19 PM
To: Jeremiah Zanin
Cc: [email protected]
Subject: Re: [cfe-commits] Fix for the -mms-bitfields commandline parameter

On Mon, Oct 8, 2012 at 2:47 PM, Jeremiah Zanin 
<[email protected]> 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

________________________________

This message, including any attachments, may contain privileged and/or 
confidential information. Any distribution or use of this email by anyone other 
than the intended recipient(s) is strictly prohibited. If you are not the 
intended recipient, please notify the sender immediately and delete all copies. 
Thank you.

Attachment: mms-bitfields.patch
Description: mms-bitfields.patch

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to