[LLVMbugs] [Bug 16631] New: [objc] clang should recover better from missing method bodies

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Jul 15 13:19:49 PDT 2013


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: unassignedclangbugs at nondot.org
          Reporter: nicolasweber at gmx.de
                CC: llvmbugs at cs.uiuc.edu
    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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130715/b77e419d/attachment.html>


More information about the llvm-bugs mailing list