|
13 | 13 |
|
14 | 14 | #include "lfort/Parse/Parser.h"
|
15 | 15 | #include "RAIIObjectsForParser.h"
|
| 16 | +#include "lfort/AST/ASTContext.h" |
16 | 17 | #include "lfort/Basic/AddressSpaces.h"
|
17 | 18 | #include "lfort/Basic/OpenCL.h"
|
18 | 19 | #include "lfort/Basic/TargetInfo.h"
|
@@ -3355,6 +3356,7 @@ void Parser::ParseDeclarationTypeSpec(DeclSpec &DS,
|
3355 | 3356 | break; }
|
3356 | 3357 | case tok::kw_character: {
|
3357 | 3358 | DeclSpec::TST T = DeclSpec::TST_char;
|
| 3359 | + bool LenProvided = false; |
3358 | 3360 | if (NextToken().isInLine(tok::l_paren) || NextToken().isInLine(tok::star)) {
|
3359 | 3361 | bool OldStyle = NextToken().isInLine(tok::star);
|
3360 | 3362 | unsigned KindValue;
|
@@ -3386,11 +3388,23 @@ void Parser::ParseDeclarationTypeSpec(DeclSpec &DS,
|
3386 | 3388 | }
|
3387 | 3389 |
|
3388 | 3390 | if (!LenValueLoc.isInvalid()) {
|
| 3391 | + LenProvided = true; |
3389 | 3392 | DeclaratorChunks.push_back(DeclaratorChunk::getArray(0, false, 0,
|
3390 | 3393 | LenValue.release(), LenValueLoc, LenValueLoc));
|
3391 | 3394 | }
|
3392 | 3395 | }
|
3393 | 3396 |
|
| 3397 | + // The default length is 1. |
| 3398 | + if (!LenProvided) { |
| 3399 | + QualType SizeTy = Actions.getASTContext().getSizeType(); |
| 3400 | + unsigned SizeSize = Actions.getASTContext().getTypeSize(SizeTy); |
| 3401 | + DeclaratorChunks.push_back(DeclaratorChunk::getArray(0, false, 0, |
| 3402 | + IntegerLiteral::Create(Actions.getASTContext(), |
| 3403 | + llvm::APInt(SizeSize, 1), |
| 3404 | + SizeTy, SourceLocation()), |
| 3405 | + Loc, Loc)); |
| 3406 | + } |
| 3407 | + |
3394 | 3408 | isInvalid |= DS.SetTypeSpecType(T, Loc, PrevSpec, DiagID);
|
3395 | 3409 | break; }
|
3396 | 3410 | // FIXME: everything else
|
|
0 commit comments