@synchronized

@synchronized doesn't seem to be supported at all by the ObjC parser:

CookieJar:~ keith$ cat > test.m
void foo(id o) { @synchronized(o) {} }
CookieJar:~ keith$ gcc -Wall -W -c test.m
CookieJar:~ keith$ clang -fsyntax-only test.m
test.m:1:18: error: unexpected '@' in program
void foo(id o) { @synchronized(o) {} }
                 ^
test.m:1:38: error: expected ';' after expression
void foo(id o) { @synchronized(o) {} }
                                     ^
Assertion failed: (E && "ActOnExprStmt(): missing expression"),
function ActOnExprStmt, file SemaStmt.cpp, line 27.

-Keith

Parse/ParseStmt.cpp:/// [OBC] objc-synchronized-statement [TODO]

:slight_smile:

- fariborz

Parse/ParseStmt.cpp:/// [OBC] objc-synchronized-statement [TODO]

Heh, whoops, missed that :confused:

> Assertion failed: (E && "ActOnExprStmt(): missing expression"),
> function ActOnExprStmt, file SemaStmt.cpp, line 27.

The assertion is real and unrelated, however:

CookieJar:~ keith$ cat test2.m
void foo(id o) { @thisonegoesto11(o) {} }
CookieJar:~ keith$ gcc -Wall -W -fsyntax-only test2.m
test2.m: In function 'foo':
test2.m:1: error: stray '@' in program
test2.m:1: warning: implicit declaration of function 'thisonegoesto11'
test2.m:1: error: syntax error before '{' token
CookieJar:~ keith$ clang -fsyntax-only test2.m
test2.m:1:18: error: unexpected '@' in program
void foo(id o) { @thisonegoesto11(o) {} }
                 ^
test2.m:1:41: error: expected ';' after expression
void foo(id o) { @thisonegoesto11(o) {} }
                                        ^
Assertion failed: (E && "ActOnExprStmt(): missing expression"),
function ActOnExprStmt, file SemaStmt.cpp, line 27.

-Keith

Fix attached.

Here's a testcase:
void foo() {@unknown;}
void foo() {@;}

And we might want to fix Parser::ExprResult to be a bit more obvious,
since the mistake of returning 0 rather than true on error is rather
widespread.

(It doesn't affect correctness, but I decided to get rid of the
SkipUntil call; it doesn't clearly improve the diagnostics in
general.)

-Eli

objcatfix.txt (1.22 KB)

Hmm, actually, I withdraw this statement; it isn't really common. I
did find another similar crash, though.

Testcase:
void a() {goto A;

-Eli

Fixed, thanks!

-Chris