easyaspi314 added inline comments.

================
Comment at: bindings/python/tests/cindex/test_diagnostics.py:18
         self.assertEqual(tu.diagnostics[0].spelling,
-                'control reaches end of non-void function')
+                'non-void function does not return a value')
 
----------------
Quuxplusone wrote:
> rsmith wrote:
> > It seems like part of the problem here is that "non-void function" is 
> > sort-of nonsense due to a few missing words. How about:
> > 
> > > "control can reach end of function with non-void return type"
> > 
> > or similar?
> > 
> > I think we still need the mention of control flow, because we're *not* 
> > saying the function contains no return statements, we're saying there's a 
> > control flow path that reaches the end of the function.
> I think OP's issue here is that the current message about "control" is 
> intrinsically confusing. //Of course// "control can reach end of function"; 
> if control never reaches the end of the function, you must have an infinite 
> loop somewhere! The important missing piece of the current message is that 
> control reaches the end of the function //without encountering any return 
> statement//.
> 
> > we're *not* saying the function contains no return statements
> 
> Not sure, but I think in this case we //are// saying that. There's a 
> different message, "non-void function //might// not return a value," for 
> those other cases.
> 
> However, if I'm wrong about that, then another wording option close to OP's 
> suggestion would be "non-void function does not //always// return a value" / 
> "non-void function might not //always// return a value."
> I think we still need the mention of control flow.

I see where you are going.

However, I have another idea, but I can't implement it myself.

What if we give the user a note like this:

```
int someCondition;

int a() {
    if (someCondition) {
        return 3;
    }
}
```
```
foo.c:3:1: warning: non-void function might not return a value [-Wreturn-type]
int a() {
^
foo.c:4:5: note: assuming 'someCondition' is false
    if (someCondition) {
    ^
foo.c:7:1: note: control flow reaches end of function without a return value
}
^
1 warning generated.
```



Repository:
  rC Clang

https://reviews.llvm.org/D45643



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D45643: [Faili... easyaspi314 (Devin) via Phabricator via cfe-commits
    • [PATCH] D45643: [... easyaspi314 (Devin) via Phabricator via cfe-commits

Reply via email to