Skip to content

Commit 76ad937

Browse files
committed
MSVC supports multiple __declspec specifiers
This isn't obvious from Microsoft's grammar, but does appear in header files shipped with Visual Studio.
1 parent 9c7e4f5 commit 76ad937

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

regression/ansi-c/VS_extensions1/main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ __declspec(thread) int thread_local;
2020

2121
struct __declspec(dllimport) some_struct_tag { int x; };
2222

23+
typedef union __declspec(intrin_type) __declspec(align(8)) u {
24+
int x;
25+
int y;
26+
} u2;
27+
2328
//__delegate int GetDayOfWeek();
2429

2530
// __event

src/ansi-c/parser.y

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1440,7 +1440,20 @@ msc_declspec_opt:
14401440
{
14411441
init($$, ID_nil);
14421442
}
1443-
| msc_declspec
1443+
| msc_declspec_opt msc_declspec
1444+
{
1445+
if(parser_stack($1).is_not_nil())
1446+
{
1447+
$$ = $1;
1448+
exprt::operandst &operands = parser_stack($1).operands();
1449+
operands.insert(
1450+
operands.end(),
1451+
parser_stack($2).operands().begin(),
1452+
parser_stack($2).operands().end());
1453+
}
1454+
else
1455+
$$ = $2;
1456+
}
14441457
;
14451458

14461459
storage_class:

0 commit comments

Comments
 (0)