http://llvm.org/bugs/show_bug.cgi?id=16631

            Bug ID: 16631
           Summary: [objc] clang should recover better from missing method
                    bodies
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified

I copied an "@implementation" section from a .h file and deleted all the method
bodies. I accidentally forgot to change "@implementation" to "@interface". This
confuses clang a lot:

Nicos-MacBook-Pro:src thakis$ cat test.mm
#import <Cocoa/Cocoa.h>

@interface A
@end

@implementation A (Foo)
- (void)doFoo:(NSString*)s;
@end

void f(A* a) {
  [a doFoo:@"asdf"];
}
Nicos-MacBook-Pro:src thakis$ third_party/llvm-build/Release+Asserts/bin/clang
-c test.mm -Wextra
test.mm:7:27: warning: semicolon before method body is ignored
[-Wsemicolon-before-method-body]
- (void)doFoo:(NSString*)s;
                          ^
test.mm:8:1: error: expected method body
@end
^
test.mm:11:4: error: use of undeclared identifier 'a'
  [a doFoo:@"asdf"];
   ^
test.mm:7:26: warning: unused parameter 's' [-Wunused-parameter]
- (void)doFoo:(NSString*)s;
                         ^
test.mm:12:2: error: missing '@end'
}
 ^
test.mm:6:1: note: implementation started here
@implementation A (Foo)
^
2 warnings and 3 errors generated.




If a method ends with a ';' and then isn't followed by '{', clang should diag
"expected body" and then continue parsing on the next line. Then this would
show only a single diag instead of more or less 1 for every source line after
the error.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to