r179743 - [Parser] Handle #pragma pack/align inside C structs.
Argyrios Kyrtzidis
akyrtzi at gmail.com
Wed Apr 17 18:42:35 PDT 2013
Author: akirtzidis
Date: Wed Apr 17 20:42:35 2013
New Revision: 179743
URL: http://llvm.org/viewvc/llvm-project?rev=179743&view=rev
Log:
[Parser] Handle #pragma pack/align inside C structs.
Fixes PR13580. Patch by Serge Pavlov!
Modified:
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/test/Parser/pragma-options.c
cfe/trunk/test/Parser/pragma-pack.c
Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=179743&r1=179742&r2=179743&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Wed Apr 17 20:42:35 2013
@@ -3230,6 +3230,16 @@ void Parser::ParseStructUnionBody(Source
continue;
}
+ if (Tok.is(tok::annot_pragma_pack)) {
+ HandlePragmaPack();
+ continue;
+ }
+
+ if (Tok.is(tok::annot_pragma_align)) {
+ HandlePragmaAlign();
+ continue;
+ }
+
if (!Tok.is(tok::at)) {
struct CFieldCallback : FieldCallback {
Parser &P;
Modified: cfe/trunk/test/Parser/pragma-options.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/pragma-options.c?rev=179743&r1=179742&r2=179743&view=diff
==============================================================================
--- cfe/trunk/test/Parser/pragma-options.c (original)
+++ cfe/trunk/test/Parser/pragma-options.c Wed Apr 17 20:42:35 2013
@@ -20,3 +20,15 @@
#pragma align=reset
#pragma align=mac68k
#pragma align=power
+
+// PR13580
+struct S
+{
+ char a[3];
+#pragma align=packed
+ struct T
+ {
+ char b;
+ int c;
+ } d;
+};
Modified: cfe/trunk/test/Parser/pragma-pack.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/pragma-pack.c?rev=179743&r1=179742&r2=179743&view=diff
==============================================================================
--- cfe/trunk/test/Parser/pragma-pack.c (original)
+++ cfe/trunk/test/Parser/pragma-pack.c Wed Apr 17 20:42:35 2013
@@ -30,3 +30,17 @@
_Pragma("pack(push)")
/* expected-warning {{expected integer or identifier in '#pragma pack'}}*/ _Pragma("pack(push,)")
+
+// PR13580
+struct S
+{
+ char a[3];
+#pragma pack(1)
+ struct T
+ {
+ char b;
+ int c;
+ } d;
+#pragma pack()
+ int e;
+};
More information about the cfe-commits
mailing list