diff options
-rw-r--r-- | lib/Parse/ParseExpr.cpp | 13 | ||||
-rw-r--r-- | test/Parser/offsetof.c | 7 |
2 files changed, 14 insertions, 6 deletions
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp index 13b32acd5b..ee2f209fff 100644 --- a/lib/Parse/ParseExpr.cpp +++ b/lib/Parse/ParseExpr.cpp @@ -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 if (Ty.isInvalid()) { Res = ExprError(); - else + } else { Res = Actions.ActOnBuiltinOffsetOf(CurScope, StartLoc, TypeLoc, Ty.get(), &Comps[0], Comps.size(), ConsumeParen()); + } break; - } else { - // Error occurred. - return ExprError(); } } break; diff --git a/test/Parser/offsetof.c b/test/Parser/offsetof.c new file mode 100644 index 0000000000..6c4e3feaa6 --- /dev/null +++ b/test/Parser/offsetof.c @@ -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 '('}} |