[clang] Improve diagnostics for auto-return-type function if the return expr had...
authorHaojian Wu <hokein.wu@gmail.com>
Mon, 30 Nov 2020 08:18:42 +0000 (09:18 +0100)
committerHaojian Wu <hokein.wu@gmail.com>
Mon, 30 Nov 2020 08:19:15 +0000 (09:19 +0100)
commitec6c5e920a89db0e1c5f73b8349ee0b84192072d
tree271c4ad25986c84c0d94b1b60bde070e0ec5146d
parentb6e04ac5aa881c1fbb66da884b04e48dfb102474
[clang] Improve diagnostics for auto-return-type function if the return expr had an error.

Given the following case:

```
auto k() {
  return undef();
  return 1;
}
```

Prior to the patch, clang emits an `cannot initialize return object of type
'auto' with an rvalue of type 'int'` diagnostic on the second return
(because the return type of the function cannot be deduced from the first contain-errors return).

This patch suppresses this error.

Differential Revision: https://reviews.llvm.org/D92211
clang/lib/Sema/SemaStmt.cpp
clang/test/SemaCXX/attr-target-mv.cpp
clang/test/SemaCXX/cxx1y-deduced-return-type.cpp
clang/test/SemaCXX/lambda-expressions.cpp