Author: aaronballman Date: Tue Jan 19 16:54:26 2016 New Revision: 258213 URL: http://llvm.org/viewvc/llvm-project?rev=258213&view=rev Log: Allow __attribute__((mode)) to appertain to field declarations again. Corrects compile issues with LibreOffice.
Patch by Stephan Bergmann Modified: cfe/trunk/include/clang/Basic/Attr.td cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/include/clang/Sema/AttributeList.h cfe/trunk/lib/Sema/SemaDeclAttr.cpp cfe/trunk/test/Sema/attr-mode.c Modified: cfe/trunk/include/clang/Basic/Attr.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=258213&r1=258212&r2=258213&view=diff ============================================================================== --- cfe/trunk/include/clang/Basic/Attr.td (original) +++ cfe/trunk/include/clang/Basic/Attr.td Tue Jan 19 16:54:26 2016 @@ -879,8 +879,8 @@ def MipsInterrupt : InheritableAttr, Tar 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]; } Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=258213&r1=258212&r2=258213&view=diff ============================================================================== --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Jan 19 16:54:26 2016 @@ -2441,7 +2441,8 @@ def warn_attribute_wrong_decl_type : War "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< Modified: cfe/trunk/include/clang/Sema/AttributeList.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?rev=258213&r1=258212&r2=258213&view=diff ============================================================================== --- cfe/trunk/include/clang/Sema/AttributeList.h (original) +++ cfe/trunk/include/clang/Sema/AttributeList.h Tue Jan 19 16:54:26 2016 @@ -855,7 +855,8 @@ enum AttributeDeclKind { ExpectedStructOrTypedef, ExpectedObjectiveCInterfaceOrProtocol, ExpectedKernelFunction, - ExpectedFunctionWithProtoType + ExpectedFunctionWithProtoType, + ExpectedVariableFieldOrTypedef }; } // end namespace clang Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=258213&r1=258212&r2=258213&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original) +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Tue Jan 19 16:54:26 2016 @@ -3392,7 +3392,7 @@ static void handleModeAttr(Sema &S, Decl 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. @@ -3465,7 +3465,7 @@ static void handleModeAttr(Sema &S, Decl 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, Modified: cfe/trunk/test/Sema/attr-mode.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-mode.c?rev=258213&r1=258212&r2=258213&view=diff ============================================================================== --- cfe/trunk/test/Sema/attr-mode.c (original) +++ cfe/trunk/test/Sema/attr-mode.c Tue Jan 19 16:54:26 2016 @@ -24,8 +24,8 @@ typedef unsigned unwind_word __attribute 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]; @@ -76,3 +76,7 @@ void test_TCtype(c128ibm *a) { f_ft128_c #else #error Unknown test architecture. #endif + +struct S { + int n __attribute((mode(HI))); +}; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits