Add ms_struct attribute on record typee
(and ignore it for now) - wip. llvm-svn: 130224
This commit is contained in:
parent
a9b630e4d7
commit
6b4e26bee2
|
|
@ -255,6 +255,10 @@ def Final : InheritableAttr {
|
|||
let Spellings = [];
|
||||
}
|
||||
|
||||
def MsStruct : InheritableAttr {
|
||||
let Spellings = ["__ms_struct__"];
|
||||
}
|
||||
|
||||
def Format : InheritableAttr {
|
||||
let Spellings = ["format"];
|
||||
let Args = [StringArgument<"Type">, IntArgument<"FormatIdx">,
|
||||
|
|
|
|||
|
|
@ -235,6 +235,7 @@ public:
|
|||
AT_weak_import,
|
||||
AT_reqd_wg_size,
|
||||
AT_init_priority,
|
||||
AT_MsStruct,
|
||||
IgnoredAttribute,
|
||||
UnknownAttribute
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4905,6 +4905,9 @@ public:
|
|||
/// a the record decl, to handle '#pragma pack' and '#pragma options align'.
|
||||
void AddAlignmentAttributesForRecord(RecordDecl *RD);
|
||||
|
||||
/// AddMsStructLayoutForRecord - Adds ms_struct layout attribute to record.
|
||||
void AddMsStructLayoutForRecord(RecordDecl *RD);
|
||||
|
||||
/// FreePackedContext - Deallocate and null out PackContext.
|
||||
void FreePackedContext();
|
||||
|
||||
|
|
|
|||
|
|
@ -202,5 +202,6 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name) {
|
|||
.Case("opencl_kernel_function", AT_opencl_kernel_function)
|
||||
.Case("uuid", AT_uuid)
|
||||
.Case("pcs", AT_pcs)
|
||||
.Case("ms_struct", AT_MsStruct)
|
||||
.Default(UnknownAttribute);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -129,6 +129,12 @@ void Sema::AddAlignmentAttributesForRecord(RecordDecl *RD) {
|
|||
}
|
||||
}
|
||||
|
||||
void Sema::AddMsStructLayoutForRecord(RecordDecl *RD) {
|
||||
if (!MSStructPragmaOn)
|
||||
return;
|
||||
RD->addAttr(::new (Context) MsStructAttr(SourceLocation(), Context));
|
||||
}
|
||||
|
||||
void Sema::ActOnPragmaOptionsAlign(PragmaOptionsAlignKind Kind,
|
||||
SourceLocation PragmaLoc,
|
||||
SourceLocation KindLoc) {
|
||||
|
|
|
|||
|
|
@ -7094,6 +7094,8 @@ CreateNewDecl:
|
|||
// the #pragma tokens are effectively skipped over during the
|
||||
// parsing of the struct).
|
||||
AddAlignmentAttributesForRecord(RD);
|
||||
|
||||
AddMsStructLayoutForRecord(RD);
|
||||
}
|
||||
|
||||
// If this is a specialization of a member class (of a class template),
|
||||
|
|
|
|||
|
|
@ -261,6 +261,13 @@ static void HandlePackedAttr(Decl *d, const AttributeList &Attr, Sema &S) {
|
|||
S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();
|
||||
}
|
||||
|
||||
static void HandleMsStructAttr(Decl *d, const AttributeList &Attr, Sema &S) {
|
||||
if (TagDecl *TD = dyn_cast<TagDecl>(d))
|
||||
TD->addAttr(::new (S.Context) MsStructAttr(Attr.getLoc(), S.Context));
|
||||
else
|
||||
S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();
|
||||
}
|
||||
|
||||
static void HandleIBAction(Decl *d, const AttributeList &Attr, Sema &S) {
|
||||
// check the attribute arguments.
|
||||
if (Attr.getNumArgs() > 0) {
|
||||
|
|
@ -2890,6 +2897,7 @@ static void ProcessInheritableDeclAttr(Scope *scope, Decl *D,
|
|||
HandleInitPriorityAttr(D, Attr, S); break;
|
||||
|
||||
case AttributeList::AT_packed: HandlePackedAttr (D, Attr, S); break;
|
||||
case AttributeList::AT_MsStruct: HandleMsStructAttr (D, Attr, S); break;
|
||||
case AttributeList::AT_section: HandleSectionAttr (D, Attr, S); break;
|
||||
case AttributeList::AT_unavailable: HandleUnavailableAttr (D, Attr, S); break;
|
||||
case AttributeList::AT_unused: HandleUnusedAttr (D, Attr, S); break;
|
||||
|
|
|
|||
|
|
@ -17,3 +17,18 @@ struct foo
|
|||
char c;
|
||||
};
|
||||
|
||||
|
||||
struct {
|
||||
unsigned long bf_1 : 12;
|
||||
unsigned long : 0;
|
||||
unsigned long bf_2 : 12;
|
||||
} __attribute__((__ms_struct__)) t1;
|
||||
|
||||
struct S {
|
||||
double __attribute__((ms_struct)) d; // expected-warning {{'ms_struct' attribute ignored}}
|
||||
unsigned long bf_1 : 12;
|
||||
unsigned long : 0;
|
||||
unsigned long bf_2 : 12;
|
||||
} __attribute__((ms_struct)) t2;
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue