Skip to content

Commit 3ad65e7

Browse files
committed
Improve parsing of concept names
1 parent 9ac29c3 commit 3ad65e7

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

src/parser/cxx/parser.cc

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,17 +1417,25 @@ auto Parser::parse_id_expression(IdExpressionAST*& yyast,
14171417

14181418
if (unqualifiedId) {
14191419
auto name = convertName(unqualifiedId);
1420-
ast->symbol = Lookup{scope_}(nestedNameSpecifier, name);
1420+
const Name* componentName = name;
1421+
if (auto templateId = name_cast<TemplateId>(name))
1422+
componentName = templateId->name();
1423+
ast->symbol = Lookup{scope_}(nestedNameSpecifier, componentName);
14211424
}
14221425

14231426
if (ctx == IdExpressionContext::kExpression) {
14241427
if (ast->symbol) {
1425-
ast->type = control_->remove_reference(ast->symbol->type());
1426-
1427-
if (auto enumerator = symbol_cast<EnumeratorSymbol>(ast->symbol)) {
1428+
if (auto conceptSymbol = symbol_cast<ConceptSymbol>(ast->symbol)) {
1429+
ast->type = control_->getBoolType();
14281430
ast->valueCategory = ValueCategory::kPrValue;
14291431
} else {
1430-
ast->valueCategory = ValueCategory::kLValue;
1432+
ast->type = control_->remove_reference(ast->symbol->type());
1433+
1434+
if (auto enumerator = symbol_cast<EnumeratorSymbol>(ast->symbol)) {
1435+
ast->valueCategory = ValueCategory::kPrValue;
1436+
} else {
1437+
ast->valueCategory = ValueCategory::kLValue;
1438+
}
14311439
}
14321440
}
14331441
}
@@ -5650,6 +5658,11 @@ auto Parser::parse_named_type_specifier(SpecifierAST*& yyast, DeclSpecs& specs)
56505658
}
56515659

56525660
if (auto templateId = ast_cast<SimpleTemplateIdAST>(unqualifiedId)) {
5661+
if (auto conceptSymbol =
5662+
symbol_cast<ConceptSymbol>(templateId->primaryTemplateSymbol)) {
5663+
if (!lookat(TokenKind::T_AUTO)) return false;
5664+
}
5665+
56535666
if (auto symbol = instantiate(templateId)) {
56545667
specs.type = symbol->type();
56555668
}

0 commit comments

Comments
 (0)