LGTM with nits fixed.

--- lib/Sema/SemaDecl.cpp (revision 182601)
+++ lib/Sema/SemaDecl.cpp (working copy)
@@ -10680,10 +10680,14 @@
       // C++ [class.union]p1: If a union contains a member of reference
type,
-      // the program is ill-formed.
+      // the program is ill-formed.  Except when compiling with MSVC
extensions
+      // enabled.

This should be a complete sentence.

       if (EltTy->isReferenceType()) {
-        Diag(NewFD->getLocation(),
diag::err_union_member_of_reference_type)
+        Diag(NewFD->getLocation(), getLangOpts().MicrosoftExt ?

^ trailing space

+
 diag::ext_union_member_of_reference_type :
+
 diag::err_union_member_of_reference_type)
           << NewFD->getDeclName() << EltTy;
+        if (!getLangOpts().MicrosoftExt)
         NewFD->setInvalidDecl();

NewFD->setInvalidDecl() needs to be indented.

       }
     }



On Thu, May 30, 2013 at 9:36 AM, Aaron Ballman <[email protected]>wrote:

> Microsoft has a language extension which allows union members to be
> references.  What's more, they use this language extension in their
> ATL header files (which come as part of MFC and the Win32 SDK).
> Basically, they have code like this:
>
> struct s {
>   union {
>      foo *fp;
>      foo &fr;
>     };
>
>     s( foo &f ) : fr( f ) {}
>     s( foo *f ) : fp( f ) {}
> };
>
> This patch enables support for union members to be references when
> compiling with Microsoft extensions, and addresses PR13737.
>
> ~Aaron
>
> _______________________________________________
> cfe-commits mailing list
> [email protected]
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to