Skip to content

Commit

Permalink
CTFE: new char[n] now creates a string literal
Browse files Browse the repository at this point in the history
Instead of an array literal. This fixes the CTFE test case in bug 6457.
  • Loading branch information
Don Clugston committed Aug 9, 2011
1 parent d4702f7 commit df2b9cd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/interpret.c
Original file line number Diff line number Diff line change
Expand Up @@ -2060,8 +2060,14 @@ Expression *NewExp::interpret(InterState *istate, CtfeGoal goal)
if (lenExpr == EXP_CANT_INTERPRET)
return EXP_CANT_INTERPRET;
size_t len = (size_t)(lenExpr->toInteger());
Type *elemType = ((TypeArray *)newtype)->next;
if (elemType->ty == Tchar || elemType->ty == Twchar
|| elemType->ty == Tdchar)
return createBlockDuplicatedStringLiteral(newtype,
(unsigned)(elemType->defaultInitLiteral()->toInteger()),
len, elemType->size());
return createBlockDuplicatedArrayLiteral(newtype,
((TypeArray *)newtype)->next->defaultInitLiteral(),
elemType->defaultInitLiteral(),
len);
}
if (newtype->toBasetype()->ty == Tstruct)
Expand Down

0 comments on commit df2b9cd

Please sign in to comment.