Skip to content

Commit

Permalink
Revert "fix Issue 23875 23880 (#15172)"
Browse files Browse the repository at this point in the history
This reverts commit c3a960d.
  • Loading branch information
dkorpel committed May 7, 2023
1 parent 54b6a2f commit 1474d36
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 89 deletions.
62 changes: 18 additions & 44 deletions compiler/src/dmd/cparse.d
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,6 @@ final class CParser(AST) : Parser!AST
// atomic-type-specifier or type_qualifier
case TOK._Atomic:

case TOK.__attribute__:

Ldeclaration:
{
cparseDeclaration(LVL.local);
Expand Down Expand Up @@ -2712,34 +2710,20 @@ final class CParser(AST) : Parser!AST
*
* Params:
* declarator = declarator kind
* tbase = base type to start with
* t = base type to start with
* pident = set to Identifier if there is one, null if not
* specifier = specifiers in and out
* Returns:
* type declared. If a TypeFunction is returned, this.symbols is the
* symbol table for the parameter-type-list, which will contain any
* declared struct, union or enum tags.
*/
private AST.Type cparseDeclarator(DTR declarator, AST.Type tbase,
private AST.Type cparseDeclarator(DTR declarator, AST.Type t,
out Identifier pident, ref Specifier specifier)
{
//printf("cparseDeclarator(%d, %p)\n", declarator, t);
AST.Types constTypes; // all the Types that will need `const` applied to them

/* Insert tx -> t into
* ts -> ... -> t
* so that
* ts -> ... -> tx -> t
*/
static void insertTx(ref AST.Type ts, AST.Type tx, AST.Type t)
{
AST.Type* pt;
for (pt = &ts; *pt != t; pt = &(cast(AST.TypeNext)*pt).next)
{
}
*pt = tx;
}

AST.Type parseDecl(AST.Type t)
{
AST.Type ts;
Expand Down Expand Up @@ -2805,6 +2789,20 @@ final class CParser(AST) : Parser!AST
// parse DeclaratorSuffixes
while (1)
{
/* Insert tx -> t into
* ts -> ... -> t
* so that
* ts -> ... -> tx -> t
*/
static void insertTx(ref AST.Type ts, AST.Type tx, AST.Type t)
{
AST.Type* pt;
for (pt = &ts; *pt != t; pt = &(cast(AST.TypeNext)*pt).next)
{
}
*pt = tx;
}

switch (token.value)
{
case TOK.leftBracket:
Expand Down Expand Up @@ -2917,17 +2915,7 @@ final class CParser(AST) : Parser!AST
return ts;
}

auto t = parseDecl(tbase);

if (specifier.vector_size)
{
auto length = new AST.IntegerExp(token.loc, specifier.vector_size / tbase.size(), AST.Type.tuns32);
auto tsa = new AST.TypeSArray(tbase, length);
AST.Type tv = new AST.TypeVector(tsa);
specifier.vector_size = 0; // used it up

insertTx(t, tv, tbase); // replace tbase with tv
}
t = parseDecl(t);

/* Because const is transitive, cannot assemble types from
* fragments. Instead, types to be annotated with const are put
Expand Down Expand Up @@ -3565,19 +3553,7 @@ final class CParser(AST) : Parser!AST
{
nextToken();
check(TOK.leftParenthesis);
if (token.value == TOK.int32Literal)
{
const n = token.unsvalue;
if (n < 1 || n & (n - 1) || ushort.max < n)
error("__attribute__((vector_size(%lld))) must be an integer positive power of 2 and be <= 32,768", cast(ulong)n);
specifier.vector_size = cast(uint) n;
nextToken();
}
else
{
error("value for vector_size expected, not `%s`", token.toChars());
nextToken();
}
cparseConstantExp(); // TODO implement

Check warning on line 3556 in compiler/src/dmd/cparse.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/cparse.d#L3556

Added line #L3556 was not covered by tests
check(TOK.rightParenthesis);
}
else
Expand Down Expand Up @@ -4718,7 +4694,6 @@ final class CParser(AST) : Parser!AST
// atomic-type-specifier
case TOK._Atomic:
case TOK.typeof_:
case TOK.__attribute__:
t = peek(t);
if (t.value != TOK.leftParenthesis ||
!skipParens(t, &t))
Expand Down Expand Up @@ -4984,7 +4959,6 @@ final class CParser(AST) : Parser!AST
bool dllexport; /// dllexport attribute
bool _deprecated; /// deprecated attribute
AST.Expression depMsg; /// deprecated message
uint vector_size; /// positive power of 2 multipe of base type size

SCW scw; /// storage-class specifiers
MOD mod; /// type qualifiers
Expand Down
3 changes: 0 additions & 3 deletions compiler/src/dmd/initsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -587,9 +587,6 @@ extern(C++) Initializer initializerSemantic(Initializer init, Scope* sc, ref Typ
*/
t = t.toBasetype();

if (auto tv = t.isTypeVector())
t = tv.basetype;

/* If `{ expression }` return the expression initializer
*/
ExpInitializer isBraceExpression()
Expand Down
28 changes: 0 additions & 28 deletions compiler/test/compilable/test23875.c

This file was deleted.

13 changes: 0 additions & 13 deletions compiler/test/fail_compilation/test23875.c

This file was deleted.

1 change: 0 additions & 1 deletion druntime/src/importc.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#define __volatile__ volatile
#define __attribute __attribute__
#define __alignof _Alignof
#define __vector_size__ vector_size

/********************
* Clang nullability extension used by macOS headers.
Expand Down

0 comments on commit 1474d36

Please sign in to comment.