diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2009-06-27 20:38:33 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2009-06-27 20:38:33 +0000 |
commit | 5e774b1333e9a0f1168274fbf1c4851bfc0f210a (patch) | |
tree | c3bd0ca69b985c8dc77e97bd3b98ba4cd6876bf8 | |
parent | 0799d916e1da65d9eebd0e05859b62039ef97316 (diff) | |
download | bcm5719-llvm-5e774b1333e9a0f1168274fbf1c4851bfc0f210a.tar.gz bcm5719-llvm-5e774b1333e9a0f1168274fbf1c4851bfc0f210a.zip |
Fix the parser error hanlding for __builtin_offsetof to actually print
out an error for a malformed __builtin_offsetof.
llvm-svn: 74388
-rw-r--r-- | clang/lib/Parse/ParseExpr.cpp | 13 | ||||
-rw-r--r-- | clang/test/Parser/offsetof.c | 7 |
2 files changed, 14 insertions, 6 deletions
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp index 13b32acd5b2..ee2f209fff3 100644 --- a/clang/lib/Parse/ParseExpr.cpp +++ b/clang/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/clang/test/Parser/offsetof.c b/clang/test/Parser/offsetof.c new file mode 100644 index 00000000000..6c4e3feaa69 --- /dev/null +++ b/clang/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 '('}} |