Index: include/clang/Basic/Attr.td =================================================================== --- include/clang/Basic/Attr.td +++ include/clang/Basic/Attr.td @@ -1397,7 +1397,7 @@ } def Section : InheritableAttr { - let Spellings = [GCC<"section">, Declspec<"allocate">]; + let Spellings = [GCC<"section">, Declspec<"allocate">, Declspec<"code_seg">]; let Args = [StringArgument<"Name">]; let Subjects = SubjectList<[Function, GlobalVar, ObjCMethod, ObjCProperty], ErrorDiag, Index: lib/Sema/SemaDeclAttr.cpp =================================================================== --- lib/Sema/SemaDeclAttr.cpp +++ lib/Sema/SemaDeclAttr.cpp @@ -2656,6 +2656,10 @@ return; } + // code_seg only ever applies to functions. + if (Attr.getName()->getName() == "code_seg" && !isa(D)) + S.Diag(LiteralLoc, diag::err_attribute_wrong_decl_type) << Attr.getName()->getName() << 0; + unsigned Index = Attr.getAttributeSpellingListIndex(); SectionAttr *NewAttr = S.mergeSectionAttr(D, Attr.getRange(), Str, Index); if (NewAttr)