[PATCH] D119778: [clang] Add a note "deducing return type for 'foo'"

Arthur O'Dwyer via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 15 16:29:48 PST 2022


Quuxplusone added inline comments.


================
Comment at: clang/lib/Sema/SemaStmt.cpp:3805
+    if (DAR != DAR_Succeeded) {
+      if (OrigResultType.getBeginLoc().isValid())
+        Diag(OrigResultType.getBeginLoc(), diag::note_deducing_return_type_for)
----------------
> I am curious about the behavior if we removed the guard `if (OrigResultType.getBeginLoc().isValid())`.

That caused the note to be emitted in some cases without a source location (similar to https://github.com/llvm/llvm-project/issues/29054 ). I admit I should check to make sure we have a test case for each of these four `if`s, though; I suspect we don't.
```
$ cat x.cpp
auto f = []() { return x; };

$ clang++ x.cpp
x.cpp:1:24: error: use of undeclared identifier 'x'
auto f = []() { return x; };
                       ^
note: deducing return type for 'operator()'
1 error generated.
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119778/new/

https://reviews.llvm.org/D119778



More information about the cfe-commits mailing list