Fix the parser error hanlding for __builtin_offsetof to actually print

out an error for a malformed __builtin_offsetof.

llvm-svn: 74388
This commit is contained in:
Eli Friedman 2009-06-27 20:38:33 +00:00
parent 0799d916e1
commit 5e774b1333
2 changed files with 14 additions and 6 deletions

View File

@ -1172,17 +1172,18 @@ Parser::OwningExprResult Parser::ParseBuiltinPrimaryExpression() {
Comps.back().LocEnd =
MatchRHSPunctuation(tok::r_square, Comps.back().LocStart);
} else if (Tok.is(tok::r_paren)) {
if (Ty.isInvalid())
} else {
if (Tok.isNot(tok::r_paren)) {
MatchRHSPunctuation(tok::r_paren, LParenLoc);
Res = ExprError();
else
} else if (Ty.isInvalid()) {
Res = ExprError();
} else {
Res = Actions.ActOnBuiltinOffsetOf(CurScope, StartLoc, TypeLoc,
Ty.get(), &Comps[0],
Comps.size(), ConsumeParen());
}
break;
} else {
// Error occurred.
return ExprError();
}
}
break;

View File

@ -0,0 +1,7 @@
// RUN: clang-cc -fsyntax-only -verify %s
struct a { struct { int b; } x[2]; };
int a = __builtin_offsetof(struct a, x; // expected-error{{expected ')'}} expected-note{{to match this '('}}
// FIXME: This actually shouldn't give an error
int b = __builtin_offsetof(struct a, x->b); // expected-error{{expected ')'}} expected-note{{to match this '('}}