зеркало из https://github.com/microsoft/clang-1.git
Tidy up Parser::ParseTypeofSpecifier()...implement FIXME and minor restructure.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40713 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
7f28fe8e00
Коммит
9dfa7b4e32
|
@ -1414,10 +1414,12 @@ void Parser::ParseBracketDeclarator(Declarator &D) {
|
||||||
///
|
///
|
||||||
void Parser::ParseTypeofSpecifier(DeclSpec &DS) {
|
void Parser::ParseTypeofSpecifier(DeclSpec &DS) {
|
||||||
assert(Tok.getKind() == tok::kw_typeof && "Not a typeof specifier");
|
assert(Tok.getKind() == tok::kw_typeof && "Not a typeof specifier");
|
||||||
|
const IdentifierInfo *BuiltinII = Tok.getIdentifierInfo();
|
||||||
SourceLocation StartLoc = ConsumeToken();
|
SourceLocation StartLoc = ConsumeToken();
|
||||||
|
|
||||||
if (Tok.getKind() != tok::l_paren) {
|
if (Tok.getKind() != tok::l_paren) {
|
||||||
// FIXME: handle error.
|
Diag(Tok, diag::err_expected_lparen_after, BuiltinII->getName());
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
SourceLocation LParenLoc = ConsumeParen(), RParenLoc;
|
SourceLocation LParenLoc = ConsumeParen(), RParenLoc;
|
||||||
|
|
||||||
|
@ -1426,28 +1428,28 @@ void Parser::ParseTypeofSpecifier(DeclSpec &DS) {
|
||||||
|
|
||||||
assert(Ty && "Parser::ParseTypeofSpecifier(): missing type");
|
assert(Ty && "Parser::ParseTypeofSpecifier(): missing type");
|
||||||
|
|
||||||
// Match the ')'.
|
if (Tok.getKind() != tok::r_paren) {
|
||||||
if (Tok.getKind() == tok::r_paren) {
|
MatchRHSPunctuation(tok::r_paren, LParenLoc);
|
||||||
|
return;
|
||||||
|
}
|
||||||
RParenLoc = ConsumeParen();
|
RParenLoc = ConsumeParen();
|
||||||
const char *PrevSpec = 0;
|
const char *PrevSpec = 0;
|
||||||
|
// Check for duplicate type specifiers (e.g. "int typeof(int)").
|
||||||
if (DS.SetTypeSpecType(DeclSpec::TST_typeofType, StartLoc, PrevSpec, Ty))
|
if (DS.SetTypeSpecType(DeclSpec::TST_typeofType, StartLoc, PrevSpec, Ty))
|
||||||
// Duplicate type specifiers (e.g. "int typeof(int)).
|
|
||||||
Diag(StartLoc, diag::err_invalid_decl_spec_combination, PrevSpec);
|
Diag(StartLoc, diag::err_invalid_decl_spec_combination, PrevSpec);
|
||||||
} else // error
|
|
||||||
MatchRHSPunctuation(tok::r_paren, LParenLoc);
|
|
||||||
} else { // we have an expression.
|
} else { // we have an expression.
|
||||||
ExprResult Result = ParseExpression();
|
ExprResult Result = ParseExpression();
|
||||||
|
|
||||||
// Match the ')'.
|
if (Result.isInvalid || Tok.getKind() != tok::r_paren) {
|
||||||
if (!Result.isInvalid && Tok.getKind() == tok::r_paren) {
|
MatchRHSPunctuation(tok::r_paren, LParenLoc);
|
||||||
|
return;
|
||||||
|
}
|
||||||
RParenLoc = ConsumeParen();
|
RParenLoc = ConsumeParen();
|
||||||
const char *PrevSpec = 0;
|
const char *PrevSpec = 0;
|
||||||
|
// Check for duplicate type specifiers (e.g. "int typeof(int)").
|
||||||
if (DS.SetTypeSpecType(DeclSpec::TST_typeofExpr, StartLoc, PrevSpec,
|
if (DS.SetTypeSpecType(DeclSpec::TST_typeofExpr, StartLoc, PrevSpec,
|
||||||
Result.Val))
|
Result.Val))
|
||||||
// Duplicate type specifiers (e.g. "int typeof(int)).
|
|
||||||
Diag(StartLoc, diag::err_invalid_decl_spec_combination, PrevSpec);
|
Diag(StartLoc, diag::err_invalid_decl_spec_combination, PrevSpec);
|
||||||
} else // error
|
|
||||||
MatchRHSPunctuation(tok::r_paren, LParenLoc);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче