[cfe-commits] r99811 - in /cfe/trunk: include/clang/Parse/Action.h lib/Parse/ParseDeclCXX.cpp lib/Sema/Sema.h lib/Sema/SemaDeclCXX.cpp test/Sema/struct-packed-align.c test/SemaCXX/class-layout.cpp
Douglas Gregor
dgregor at apple.com
Mon Mar 29 07:42:08 PDT 2010
Author: dgregor
Date: Mon Mar 29 09:42:08 2010
New Revision: 99811
URL: http://llvm.org/viewvc/llvm-project?rev=99811&view=rev
Log:
Support __attribute__((packed)) (along with other attributes) at the
end of a struct/class/union in C++, from Justin Bogner!
Modified:
cfe/trunk/include/clang/Parse/Action.h
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/Sema/struct-packed-align.c
cfe/trunk/test/SemaCXX/class-layout.cpp
Modified: cfe/trunk/include/clang/Parse/Action.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Action.h?rev=99811&r1=99810&r2=99811&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/trunk/include/clang/Parse/Action.h Mon Mar 29 09:42:08 2010
@@ -1761,7 +1761,8 @@
virtual void ActOnFinishCXXMemberSpecification(Scope* S, SourceLocation RLoc,
DeclPtrTy TagDecl,
SourceLocation LBrac,
- SourceLocation RBrac) {
+ SourceLocation RBrac,
+ AttributeList *AttrList) {
}
//===---------------------------C++ Templates----------------------------===//
Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=99811&r1=99810&r2=99811&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Mon Mar 29 09:42:08 2010
@@ -1579,10 +1579,11 @@
// If attributes exist after class contents, parse them.
llvm::OwningPtr<AttributeList> AttrList;
if (Tok.is(tok::kw___attribute))
- AttrList.reset(ParseGNUAttributes()); // FIXME: where should I put them?
+ AttrList.reset(ParseGNUAttributes());
Actions.ActOnFinishCXXMemberSpecification(CurScope, RecordLoc, TagDecl,
- LBraceLoc, RBraceLoc);
+ LBraceLoc, RBraceLoc,
+ AttrList.get());
// C++ 9.2p2: Within the class member-specification, the class is regarded as
// complete within function bodies, default arguments,
Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=99811&r1=99810&r2=99811&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Mon Mar 29 09:42:08 2010
@@ -2502,7 +2502,8 @@
virtual void ActOnFinishCXXMemberSpecification(Scope* S, SourceLocation RLoc,
DeclPtrTy TagDecl,
SourceLocation LBrac,
- SourceLocation RBrac);
+ SourceLocation RBrac,
+ AttributeList *AttrList);
virtual void ActOnReenterTemplateScope(Scope *S, DeclPtrTy Template);
virtual void ActOnStartDelayedMemberDeclarations(Scope *S,
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=99811&r1=99810&r2=99811&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Mar 29 09:42:08 2010
@@ -2174,7 +2174,8 @@
void Sema::ActOnFinishCXXMemberSpecification(Scope* S, SourceLocation RLoc,
DeclPtrTy TagDecl,
SourceLocation LBrac,
- SourceLocation RBrac) {
+ SourceLocation RBrac,
+ AttributeList *AttrList) {
if (!TagDecl)
return;
@@ -2182,7 +2183,7 @@
ActOnFields(S, RLoc, TagDecl,
(DeclPtrTy*)FieldCollector->getCurFields(),
- FieldCollector->getCurNumFields(), LBrac, RBrac, 0);
+ FieldCollector->getCurNumFields(), LBrac, RBrac, AttrList);
CheckCompletedCXXClass(
dyn_cast_or_null<CXXRecordDecl>(TagDecl.getAs<Decl>()));
Modified: cfe/trunk/test/Sema/struct-packed-align.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/struct-packed-align.c?rev=99811&r1=99810&r2=99811&view=diff
==============================================================================
--- cfe/trunk/test/Sema/struct-packed-align.c (original)
+++ cfe/trunk/test/Sema/struct-packed-align.c Mon Mar 29 09:42:08 2010
@@ -37,6 +37,14 @@
extern int d1[sizeof(struct packed_fas) == 1 ? 1 : -1];
extern int d2[__alignof(struct packed_fas) == 1 ? 1 : -1];
+struct packed_after_fas {
+ char a;
+ int b[];
+} __attribute__((packed));
+
+extern int d1_2[sizeof(struct packed_after_fas) == 1 ? 1 : -1];
+extern int d2_2[__alignof(struct packed_after_fas) == 1 ? 1 : -1];
+
// Alignment
struct __attribute__((aligned(8))) as1 {
Modified: cfe/trunk/test/SemaCXX/class-layout.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/class-layout.cpp?rev=99811&r1=99810&r2=99811&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/class-layout.cpp (original)
+++ cfe/trunk/test/SemaCXX/class-layout.cpp Mon Mar 29 09:42:08 2010
@@ -48,6 +48,13 @@
SA(6, sizeof(H) == 1);
+struct I {
+ char b;
+ int a;
+} __attribute__((packed));
+
+SA(6_1, sizeof(I) == 5);
+
// PR5580
namespace PR5580 {
More information about the cfe-commits
mailing list