r195277 - There is no such thing as __declspec(ms_struct), this is a GNU attribute. Switched the attribute to have the proper spelling, gave it a subject, updated the warning to be more accurate, and updated the test case as appropriate.

Aaron Ballman aaron at aaronballman.com
Wed Nov 20 14:22:04 PST 2013


Author: aaronballman
Date: Wed Nov 20 16:22:04 2013
New Revision: 195277

URL: http://llvm.org/viewvc/llvm-project?rev=195277&view=rev
Log:
There is no such thing as __declspec(ms_struct), this is a GNU attribute. Switched the attribute to have the proper spelling, gave it a subject, updated the warning to be more accurate, and updated the test case as appropriate.

Modified:
    cfe/trunk/include/clang/Basic/Attr.td
    cfe/trunk/lib/Sema/SemaDeclAttr.cpp
    cfe/trunk/test/Sema/pragma-ms_struct.c

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=195277&r1=195276&r2=195277&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Wed Nov 20 16:22:04 2013
@@ -1068,7 +1068,8 @@ def MsProperty : IgnoredAttr {
 }
 
 def MsStruct : InheritableAttr {
-  let Spellings = [Declspec<"ms_struct">];
+  let Spellings = [GNU<"ms_struct">, CXX11<"gnu", "ms_struct">];
+  let Subjects = [Record];
 }
 
 def DLLExport : InheritableAttr, TargetSpecificAttr {

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=195277&r1=195276&r2=195277&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Wed Nov 20 16:22:04 2013
@@ -1278,7 +1278,8 @@ static void handleMsStructAttr(Sema &S,
                 MsStructAttr(Attr.getRange(), S.Context,
                              Attr.getAttributeSpellingListIndex()));
   else
-    S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();
+    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
+      << Attr.getName() << ExpectedStructOrUnionOrClass;
 }
 
 static void handleIBAction(Sema &S, Decl *D, const AttributeList &Attr) {

Modified: cfe/trunk/test/Sema/pragma-ms_struct.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/pragma-ms_struct.c?rev=195277&r1=195276&r2=195277&view=diff
==============================================================================
--- cfe/trunk/test/Sema/pragma-ms_struct.c (original)
+++ cfe/trunk/test/Sema/pragma-ms_struct.c Wed Nov 20 16:22:04 2013
@@ -25,7 +25,7 @@ struct {
 } __attribute__((__ms_struct__)) t1;
 
 struct S {
-		   double __attribute__((ms_struct)) d;	// expected-warning {{'ms_struct' attribute ignored}}
+		   double __attribute__((ms_struct)) d;	// expected-warning {{'ms_struct' attribute only applies to struct, union or class}}
                    unsigned long bf_1 : 12;
                    unsigned long : 0;
                    unsigned long bf_2 : 12;
@@ -36,7 +36,7 @@ enum
   A = 0,
   B,
   C
-} __attribute__((ms_struct)) e1; // expected-warning {{'ms_struct' attribute ignored}}
+} __attribute__((ms_struct)) e1; // expected-warning {{'ms_struct' attribute only applies to struct, union or class}}
 
 // rdar://10513599
 #pragma ms_struct on
@@ -52,10 +52,12 @@ typedef struct
 void *pv1;
 Foo foo;
 unsigned short fInited : 1;
-void *pv2;		
-} PackOddity;		
+void *pv2;
+} PackOddity;
 
 #pragma ms_struct off
 
 static int arr[sizeof(PackOddity) == 40 ? 1 : -1];
 
+__declspec(ms_struct) struct bad { // expected-warning {{unknown __declspec attribute 'ms_struct' ignored}}
+};





More information about the cfe-commits mailing list