forked from OSchip/llvm-project
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:
parent
0799d916e1
commit
5e774b1333
|
@ -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;
|
||||
|
|
|
@ -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 '('}}
|
Loading…
Reference in New Issue