[cfe-commits] r74388 - in /cfe/trunk: lib/Parse/ParseExpr.cpp test/Parser/offsetof.c
Eli Friedman
eli.friedman at gmail.com
Sat Jun 27 13:38:34 PDT 2009
Author: efriedma
Date: Sat Jun 27 15:38:33 2009
New Revision: 74388
URL: http://llvm.org/viewvc/llvm-project?rev=74388&view=rev
Log:
Fix the parser error hanlding for __builtin_offsetof to actually print
out an error for a malformed __builtin_offsetof.
Added:
cfe/trunk/test/Parser/offsetof.c
Modified:
cfe/trunk/lib/Parse/ParseExpr.cpp
Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=74388&r1=74387&r2=74388&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Sat Jun 27 15:38:33 2009
@@ -1172,17 +1172,18 @@
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;
Added: cfe/trunk/test/Parser/offsetof.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/offsetof.c?rev=74388&view=auto
==============================================================================
--- cfe/trunk/test/Parser/offsetof.c (added)
+++ cfe/trunk/test/Parser/offsetof.c Sat Jun 27 15:38:33 2009
@@ -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 '('}}
More information about the cfe-commits
mailing list