@@ -57,6 +57,7 @@ fn Stmt* Parser.parseStmt(Parser* p) {
5757 case KW_int ... KW_unsigned: // C type keywords
5858 case KW_const:
5959 case KW_local:
60+ case KW_tlocal:
6061 case KW_volatile:
6162 case KW_void:
6263 // checkSemi, allowLocal, !isCondition
@@ -506,10 +507,10 @@ fn Stmt* Parser.parseWhileStmt(Parser* p) {
506507fn Stmt* Parser.parseDeclStmt(Parser* p, bool checkSemi, bool allowLocal, bool isCondition) {
507508 VarDecl*[MaxMultiDecl] decls;
508509 u32 num_decls = 0;
509- bool has_local = false ;
510- if (p.tok.kind == KW_local) {
511- has_local = true;
512- if (!allowLocal) p.error("keyword 'local ' is not allowed here");
510+ bool has_local = (p.tok.kind == KW_local) ;
511+ bool has_tlocal = (p.tok.kind == KW_tlocal);
512+ if ( has_local | has_tlocal) {
513+ if (!allowLocal) p.error("keyword '%s ' is not allowed here", p.tok.kind.str() );
513514 p.consumeToken();
514515 }
515516
@@ -548,7 +549,7 @@ fn Stmt* Parser.parseDeclStmt(Parser* p, bool checkSemi, bool allowLocal, bool i
548549 case Dot:
549550 if (p.peekToken(1) == Identifier
550551 && p.peekToken(2) == LParen) {
551- if (has_local)
552+ if (has_local | has_tlocal )
552553 p.error("local qualified variables cannot have an init call");
553554 if (isCondition)
554555 p.error("cannot use an init call inside a condition");
@@ -571,7 +572,9 @@ fn Stmt* Parser.parseDeclStmt(Parser* p, bool checkSemi, bool allowLocal, bool i
571572 default:
572573 break;
573574 }
574- decls[num_decls++] = p.builder.actOnVarDecl(name, loc, &ref, assignLoc, initValue, has_local, has_init_call);
575+ VarDecl* vd = p.builder.actOnVarDecl(name, loc, &ref, assignLoc, initValue, has_local, has_init_call);
576+ if (has_tlocal) vd.setTLocal();
577+ decls[num_decls++] = vd;
575578 if (p.tok.kind != Comma)
576579 break;
577580 p.consumeToken();
@@ -628,7 +631,7 @@ fn bool Parser.isDeclaration(Parser* p) {
628631 const Kind kind = p.tok.kind;
629632 if (kind == Identifier) return p.isTypeSpec();
630633 if (kind.isTypeKeyword() && (p.peekToken(1) != Dot)) return true;
631- if (kind == KW_local) return true;
634+ if (kind == KW_local || kind == KW_tlocal ) return true;
632635 if (kind.isQualifier()) return true;
633636 return false;
634637}
0 commit comments