Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

false-positive -Wreturn-type error #51440

Open Quuxplusone opened 2 years ago

Quuxplusone commented 2 years ago
Bugzilla Link PR52473
Status NEW
Importance P normal
Reported by Mike Kaufman (mkaufman@microsoft.com)
Reported on 2021-11-10 13:04:43 -0800
Last modified on 2021-11-22 11:24:53 -0800
Version trunk
Hardware PC MacOS X
CC blitzrakete@gmail.com, comanea@microsoft.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also

This is a regression somewhere between clang revision llvmorg-14-init-7378-gaee49255 and `llvmorg-14-init-8281-gaa1d32f5 - build 7378 has expected behavior.

Repro:

  1. Save code below to file file a.m
  2. Compile code: bin/clang -Wreturn-type -Wno-objc-root-class -c -o a.o a.m
@interface Bar
- (Bar*)baz;
- (Bar*)quux;
- (int)query;
@end
@implementation Bar
- (Bar* ) baz
{
    @try {
        @throw self;
    } @catch (Bar*) {
        return self;
    }
    return (Bar*)0;
}
@end

Expected behavior: compilation is free from warnings

Actual behavior: $ bin/clang -Wreturn-type -Wno-objc-root-class -c -o a.o a.m a.m:14:1: warning: non-void function does not return a value in all control paths [-Wreturn-type] } ^ 1 warning generated.

Quuxplusone commented 2 years ago

One observation is that this warning does not appear anymore if there are not any return statements that come anywhere after the @throw statement.

Quuxplusone commented 2 years ago

It was pointed out that the issue on this page might have been a precursor to this bug: https://bugs.llvm.org/show_bug.cgi?id=46693