Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

Non-void fonction not detected by Xcode compiler; Missing return warning #121

Open
BelaSzombathelyi opened this issue Jun 29, 2016 · 5 comments

Comments

@BelaSzombathelyi
Copy link

BelaSzombathelyi commented Jun 29, 2016

The LLVM not drop warning for this:

- (int)test
{
    if (YES) {

    } else {
        @weakify(self);
        ^{
            @strongify(self);
            NSLog(@"%@",self.class);
        }();
    }
}

If I remove weakly and strongly it drop compile error.

- (int)test
{
    if (YES) {

    } else {
        ^{
            NSLog(@"%@",self.class);
        }();
    }
} // Control reaches end of non-void function
@jspahrsummers
Copy link
Owner

I'm not sure why @weakify and @strongify would have anything to do with this.

If you use explicit __weak and __strong variables, do you see the same issue?

@BelaSzombathelyi
Copy link
Author

No, I can not compile it.

- (int)test
{
    if (YES) {

    } else {
        __weak __typeof(self)weakSelf = self;
        ^{
            __strong __typeof(weakSelf) strongSelf = weakSelf;
            NSLog(@"%@",strongSelf.class);
        }();
    }
} // Control reaches end of non-void function

@BelaSzombathelyi
Copy link
Author

I use LLVM 7.1 with Xcode 7.3.1 (7D1014), (if it helps)

@jspahrsummers
Copy link
Owner

It might be the @finally embedded within the macros. I'm not sure there's a readily apparent solution here, sorry. 😕

@BelaSzombathelyi
Copy link
Author

I found the answer. If a method contains try-catch block, compiler not warning for "Non-void function"
Example:

- (int)test
{
    @try {

    } @catch (NSException *exception) {

    }
}//No error

This bug no jump between methods, only one method deep.

- (int)a
{
    [self b];
} // Control reaches end of non-void function

- (void)b
{
    @try {

    } @catch (NSException *exception) {

    }
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants