olga.a.chupina created this revision. olga.a.chupina added a reviewer: rnk. olga.a.chupina added a subscriber: cfe-commits.
This patch supports using '__unaligned' attribute in function declaration: struct UnalignedS { void foo(double) __unaligned { ; } }; void bar(void (UnalignedS::*pf)(double)__unaligned); http://reviews.llvm.org/D17709 Files: lib/Parse/ParseDecl.cpp lib/Parse/ParseTentative.cpp test/SemaCXX/MicrosoftExtensions.cpp Index: lib/Parse/ParseDecl.cpp =================================================================== --- lib/Parse/ParseDecl.cpp +++ lib/Parse/ParseDecl.cpp @@ -4808,7 +4808,9 @@ case tok::kw___thiscall: case tok::kw___vectorcall: case tok::kw___unaligned: - if (AttrReqs & AR_DeclspecAttributesParsed) { + // Allow __unaligned in function definition after a parameter list + if ((AttrReqs & AR_DeclspecAttributesParsed) || + (Tok.getKind() == tok::kw___unaligned)) { ParseMicrosoftTypeAttributes(DS.getAttributes()); continue; } Index: lib/Parse/ParseTentative.cpp =================================================================== --- lib/Parse/ParseTentative.cpp +++ lib/Parse/ParseTentative.cpp @@ -1782,7 +1782,8 @@ return TPResult::Error; // cv-qualifier-seq - while (Tok.isOneOf(tok::kw_const, tok::kw_volatile, tok::kw_restrict)) + while (Tok.isOneOf(tok::kw_const, tok::kw_volatile, tok::kw_restrict, + tok::kw___unaligned)) ConsumeToken(); // ref-qualifier[opt] Index: test/SemaCXX/MicrosoftExtensions.cpp =================================================================== --- test/SemaCXX/MicrosoftExtensions.cpp +++ test/SemaCXX/MicrosoftExtensions.cpp @@ -80,6 +80,10 @@ // __unaligned handling typedef char __unaligned *aligned_type; typedef struct UnalignedTag { int f; } __unaligned *aligned_type2; +struct UnalignedS { + void foo(double) __unaligned { ; } +}; +void bar(void (UnalignedS::*pf)(double)__unaligned); template<typename T> void h1(T (__stdcall M::* const )()) { }
Index: lib/Parse/ParseDecl.cpp =================================================================== --- lib/Parse/ParseDecl.cpp +++ lib/Parse/ParseDecl.cpp @@ -4808,7 +4808,9 @@ case tok::kw___thiscall: case tok::kw___vectorcall: case tok::kw___unaligned: - if (AttrReqs & AR_DeclspecAttributesParsed) { + // Allow __unaligned in function definition after a parameter list + if ((AttrReqs & AR_DeclspecAttributesParsed) || + (Tok.getKind() == tok::kw___unaligned)) { ParseMicrosoftTypeAttributes(DS.getAttributes()); continue; } Index: lib/Parse/ParseTentative.cpp =================================================================== --- lib/Parse/ParseTentative.cpp +++ lib/Parse/ParseTentative.cpp @@ -1782,7 +1782,8 @@ return TPResult::Error; // cv-qualifier-seq - while (Tok.isOneOf(tok::kw_const, tok::kw_volatile, tok::kw_restrict)) + while (Tok.isOneOf(tok::kw_const, tok::kw_volatile, tok::kw_restrict, + tok::kw___unaligned)) ConsumeToken(); // ref-qualifier[opt] Index: test/SemaCXX/MicrosoftExtensions.cpp =================================================================== --- test/SemaCXX/MicrosoftExtensions.cpp +++ test/SemaCXX/MicrosoftExtensions.cpp @@ -80,6 +80,10 @@ // __unaligned handling typedef char __unaligned *aligned_type; typedef struct UnalignedTag { int f; } __unaligned *aligned_type2; +struct UnalignedS { + void foo(double) __unaligned { ; } +}; +void bar(void (UnalignedS::*pf)(double)__unaligned); template<typename T> void h1(T (__stdcall M::* const )()) { }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits