[LLVMbugs] [Bug 14037] New: #pragma pack in nested struct rejected, and with poor diagnostics
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sat Oct 6 15:03:55 PDT 2012
http://llvm.org/bugs/show_bug.cgi?id=14037
Bug #: 14037
Summary: #pragma pack in nested struct rejected, and with poor
diagnostics
Product: clang
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: matti.niemenmaa+llvmbugs at iki.fi
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
clang 3.1 as well as the latest trunk version rejects the following:
struct s {
#pragma pack(push)
#pragma pack(1)
struct { char x; int y; } nested;
#pragma pack(pop)
};
int f(struct s *p) { return p->nested.x + p->nested.y; }
(The f function is there just to check from the asm that the struct is
correctly packed.)
The output from clang consists of the following fairly unhelpful errors:
$ clang -S asdf.c
asdf.c:2:9: error: type name requires a specifier or qualifier
#pragma pack(push)
^
asdf.c:2:9: error: expected member name or ';' after declaration specifiers
#pragma pack(push)
^~~~
asdf.c:1:11: error: expected ';' at end of declaration list
struct s {
^
;
asdf.c:5:9: error: type name requires a specifier or qualifier
#pragma pack(pop)
^
asdf.c:5:9: error: expected member name or ';' after declaration specifiers
#pragma pack(pop)
^~~~
asdf.c:4:37: error: expected ';' at end of declaration list
struct { char x; int y; } nested;
^
;
asdf.c:7:32: error: no member named 'nested' in 'struct s'
int f(struct s *p) { return p->nested.x + p->nested.y; }
~ ^
asdf.c:7:46: error: no member named 'nested' in 'struct s'
int f(struct s *p) { return p->nested.x + p->nested.y; }
~ ^
8 errors generated.
If the #pragmas are placed outside the top-level struct, clang compiles the
file without error. GCC 4.7.1 accepts both versions of the code.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list