Commit 9a8e724f authored by Roberto Raggi's avatar Roberto Raggi

Don't search for undefined symbols in ambiguous typeof expressions.

parent 44aa96fc
......@@ -552,6 +552,24 @@ protected:
return true;
}
virtual bool visit(SizeofExpressionAST *ast)
{
if (ast->lparen_token && ast->expression && ast->rparen_token) {
if (TypeIdAST *type_id = ast->expression->asTypeId()) {
SpecifierAST *type_specifier = type_id->type_specifier;
if (! type_id->declarator && type_specifier && ! type_specifier->next &&
type_specifier->asNamedTypeSpecifier()) {
// this sizeof expression is ambiguos, e.g.
// sizeof (a)
// `a' can be a typeid or a nested-expression.
return false;
}
}
}
return true;
}
LookupContext lookupContext(unsigned line, unsigned column) const;
private:
......
......@@ -1980,7 +1980,9 @@ class CPLUSPLUS_EXPORT SizeofExpressionAST: public ExpressionAST
{
public:
unsigned sizeof_token;
unsigned lparen_token;
ExpressionAST *expression;
unsigned rparen_token;
public:
virtual SizeofExpressionAST *asSizeofExpression()
......
......@@ -3158,7 +3158,8 @@ bool Parser::parseUnaryExpression(ExpressionAST *&node)
if (LA() == T_LPAREN) {
unsigned lparen_token = consumeToken();
if (parseTypeId(ast->expression) && LA() == T_RPAREN) {
consumeToken();
ast->lparen_token = lparen_token;
ast->rparen_token = consumeToken();
node = ast;
return true;
} else {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment