def Mode : Attr {
let Spellings = [GCC<"mode">];
- let Subjects = SubjectList<[Var, TypedefName], ErrorDiag,
- "ExpectedVariableOrTypedef">;
+ let Subjects = SubjectList<[Var, TypedefName, Field], ErrorDiag,
+ "ExpectedVariableFieldOrTypedef">;
let Args = [IdentifierArgument<"Mode">];
let Documentation = [Undocumented];
}
"Objective-C instance methods|init methods of interface or class extension declarations|"
"variables, functions and classes|Objective-C protocols|"
"functions and global variables|structs, unions, and typedefs|structs and typedefs|"
- "interface or protocol declarations|kernel functions|non-K&R-style functions}1">,
+ "interface or protocol declarations|kernel functions|non-K&R-style functions|"
+ "variables, fields and typedefs}1">,
InGroup<IgnoredAttributes>;
def err_attribute_wrong_decl_type : Error<warn_attribute_wrong_decl_type.Text>;
def warn_type_attribute_wrong_type : Warning<
ExpectedStructOrTypedef,
ExpectedObjectiveCInterfaceOrProtocol,
ExpectedKernelFunction,
- ExpectedFunctionWithProtoType
+ ExpectedFunctionWithProtoType,
+ ExpectedVariableFieldOrTypedef
};
} // end namespace clang
if (TypedefNameDecl *TD = dyn_cast<TypedefNameDecl>(D))
OldTy = TD->getUnderlyingType();
else
- OldTy = cast<VarDecl>(D)->getType();
+ OldTy = cast<ValueDecl>(D)->getType();
// Base type can also be a vector type (see PR17453).
// Distinguish between base type and base element type.
if (TypedefNameDecl *TD = dyn_cast<TypedefNameDecl>(D))
TD->setModedTypeSourceInfo(TD->getTypeSourceInfo(), NewTy);
else
- cast<VarDecl>(D)->setType(NewTy);
+ cast<ValueDecl>(D)->setType(NewTy);
D->addAttr(::new (S.Context)
ModeAttr(Attr.getRange(), S.Context, Name,
int **__attribute((mode(QI)))* i32; // expected-error{{mode attribute}}
-__attribute__((mode(QI))) int invalid_func() { return 1; } // expected-error{{'mode' attribute only applies to variables and typedefs}}
-enum invalid_enum { A1 __attribute__((mode(QI))) }; // expected-error{{'mode' attribute only applies to variables and typedefs}}
+__attribute__((mode(QI))) int invalid_func() { return 1; } // expected-error{{'mode' attribute only applies to variables, fields and typedefs}}
+enum invalid_enum { A1 __attribute__((mode(QI))) }; // expected-error{{'mode' attribute only applies to variables, fields and typedefs}}
typedef _Complex double c32 __attribute((mode(SC)));
int c32_test[sizeof(c32) == 8 ? 1 : -1];
#else
#error Unknown test architecture.
#endif
+
+struct S {
+ int n __attribute((mode(HI)));
+};