Skip to content

Commit f7a3adf

Browse files
committed
Don't interpret alignment specifiers as the type
1 parent a53a75a commit f7a3adf

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

src/cppconv/cppsemantic.d

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,6 +1014,9 @@ void analyzeSimpleDeclaration(Tree tree, immutable(Formula)* condition,
10141014
info.flags |= DeclarationFlags.constExpr;
10151015
}
10161016
}
1017+
else if (tree.nonterminalID == ParserWrapper.nonterminalIDFor!"AlignmentSpecifier")
1018+
{
1019+
}
10171020
else if (tree.nonterminalID.nonterminalIDAmong!("NameIdentifier",
10181021
"SimpleTypeSpecifierNoKeyword", "SimpleTemplateId", "DecltypeSpecifier"))
10191022
{

tests/single/test376.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
typedef unsigned size_t;
2+
3+
template <size_t Size, size_t Align, size_t Prealloc>
4+
class QVLAStorage
5+
{
6+
alignas(Align) char array[Prealloc * (Align > Size ? Align : Size)];
7+
8+
static_assert(sizeof(array));
9+
};

tests/single/test376.d

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module test376;
2+
3+
import config;
4+
import cppconvhelpers;
5+
6+
7+
extern(C++, class) struct QVLAStorage(size_t Size, size_t Align, size_t Prealloc)
8+
{
9+
private:
10+
/+ alignas(Align) +/ char[Prealloc * (Align > Size ? Align : Size)] array;
11+
12+
static assert(( (array).length ) * char.sizeof);
13+
}
14+

0 commit comments

Comments
 (0)