Index: include/clang/Basic/Attr.td =================================================================== --- include/clang/Basic/Attr.td +++ include/clang/Basic/Attr.td @@ -887,7 +887,7 @@ def Mode : Attr { let Spellings = [GCC<"mode">]; - let Subjects = SubjectList<[Var, TypedefName], ErrorDiag, + let Subjects = SubjectList<[Var, TypedefName, Field], ErrorDiag, "ExpectedVariableOrTypedef">; let Args = [IdentifierArgument<"Mode">]; let Documentation = [Undocumented]; Index: lib/Sema/SemaDeclAttr.cpp =================================================================== --- lib/Sema/SemaDeclAttr.cpp +++ lib/Sema/SemaDeclAttr.cpp @@ -3392,7 +3392,7 @@ if (TypedefNameDecl *TD = dyn_cast(D)) OldTy = TD->getUnderlyingType(); else - OldTy = cast(D)->getType(); + OldTy = cast(D)->getType(); // Base type can also be a vector type (see PR17453). // Distinguish between base type and base element type. @@ -3465,7 +3465,7 @@ if (TypedefNameDecl *TD = dyn_cast(D)) TD->setModedTypeSourceInfo(TD->getTypeSourceInfo(), NewTy); else - cast(D)->setType(NewTy); + cast(D)->setType(NewTy); D->addAttr(::new (S.Context) ModeAttr(Attr.getRange(), S.Context, Name, Index: test/Sema/attr-mode.c =================================================================== --- test/Sema/attr-mode.c +++ test/Sema/attr-mode.c @@ -76,3 +76,7 @@ #else #error Unknown test architecture. #endif + +struct S { + int n __attribute((mode(HI))); +};