]> granicus.if.org Git - clang/commitdiff
[Parser] Handle #pragma pack/align inside C structs.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Thu, 18 Apr 2013 01:42:35 +0000 (01:42 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Thu, 18 Apr 2013 01:42:35 +0000 (01:42 +0000)
Fixes PR13580. Patch by Serge Pavlov!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179743 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseDecl.cpp
test/Parser/pragma-options.c
test/Parser/pragma-pack.c

index 47826aa3b91b853965f59498abe299ac4f028f1d..a39cebccb3151aa13fc16e23c745e3a4224bd57e 100644 (file)
@@ -3230,6 +3230,16 @@ void Parser::ParseStructUnionBody(SourceLocation RecordLoc,
       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;
index 7844e7108060ad9b71e247b442f19e14f423d5ad..d168a2751a277972540e0873086c21466d6186a9 100644 (file)
 #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;
+};
index 84778cd501d05c12629e5599086078a96df687a3..172a332510a7ec4879d2eca5727e1985c3741f8c 100644 (file)
 
 _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;
+};