Skip to content

Commit 17bba2e

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

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
@@ -4522,6 +4522,12 @@ bool Parser::rClassSpec(typet &spec)
45224522
std::cout << std::string(__indent, ' ') << "Parser::rClassSpec 3\n";
45234523
#endif
45244524

4525+
if(!optAlignas(spec))
4526+
return false;
4527+
4528+
if(!optAttribute(spec))
4529+
return false;
4530+
45254531
if(lex.LookAhead(0)=='{')
45264532
{
45274533
// no tag
@@ -4531,12 +4537,6 @@ bool Parser::rClassSpec(typet &spec)
45314537
}
45324538
else
45334539
{
4534-
if(!optAlignas(spec))
4535-
return false;
4536-
4537-
if(!optAttribute(spec))
4538-
return false;
4539-
45404540
irept name;
45414541

45424542
if(!rName(name))

0 commit comments

Comments
 (0)