Skip to content

Commit fc31dfc

Browse files
committed
C++ front-end: support attributes with tag-less structs
Seen in GCC's STL.
1 parent 0889cfa commit fc31dfc

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

regression/cpp/gcc_attributes2/main.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
#ifdef __GNUC__
22
typedef int my_int16_t __attribute__((__mode__(__HI__)));
33
static_assert(sizeof(my_int16_t) == 2, "16 bit");
4+
5+
template <std::size_t _Align = __alignof__(int)>
6+
struct __attribute__((__aligned__((_Align))))
7+
{
8+
} __align;
49
#endif
510

611
int main()

src/cpp/parse.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4486,6 +4486,12 @@ bool Parser::rClassSpec(typet &spec)
44864486
std::cout << std::string(__indent, ' ') << "Parser::rClassSpec 3\n";
44874487
#endif
44884488

4489+
if(!optAlignas(spec))
4490+
return false;
4491+
4492+
if(!optAttribute(spec))
4493+
return false;
4494+
44894495
if(lex.LookAhead(0)=='{')
44904496
{
44914497
// no tag
@@ -4495,12 +4501,6 @@ bool Parser::rClassSpec(typet &spec)
44954501
}
44964502
else
44974503
{
4498-
if(!optAlignas(spec))
4499-
return false;
4500-
4501-
if(!optAttribute(spec))
4502-
return false;
4503-
45044504
irept name;
45054505

45064506
if(!rName(name))

0 commit comments

Comments
 (0)