This is an archive of the discontinued LLVM Phabricator instance.

[clang] More informative mixed namespace diagnostics
ClosedPublic

Authored by urnathan on Dec 22 2021, 5:46 AM.

Details

Summary

Continuing the improvement of std/std::experimental mixing diagnostics ...

First, let's check we get a TemplateDecl, before complaining about where it might have been found.

Second, if it came from an unexpected place, show where that location is with a 'declared here' note.

(Still an error when std and std::experimental both have decls)

Diff Detail

Event Timeline

urnathan requested review of this revision.Dec 22 2021, 5:46 AM
urnathan created this revision.
Quuxplusone requested changes to this revision.Dec 22 2021, 9:42 AM
Quuxplusone added inline comments.
clang/test/SemaCXX/co_await-range-for-exp-namespace.cpp
4

Instead of doing this -verify=expected,declared, I have another trick for you from the libcxx test suite. :) IIUC, the compiler output we expect is

../clang/test/SemaCXX/co_await-range-for-exp-namespace.cpp:53:7: warning: support for std::experimental::coroutine_traits will be removed in LLVM 15; use std::coroutine_traits instead [-Wdeprecated-experimental-coroutine]
  for co_await (auto i : arr) {} // expected-warning {{support for std::experimental::coroutine_traits will be removed}}
      ^
../clang/test/SemaCXX/Inputs/std-coroutine-exp-namespace.h:8:8: note: 'coroutine_traits' declared here
struct coroutine_traits { using promise_type = typename Ret::promise_type; };
       ^

So, down on line 53, I think we should write

MyForLoopArrayAwaiter g() {
  int arr[10] = {0};
  for co_await (auto i : arr) {}
  // expected-warning@-1 {{support for std::experimental::coroutine_traits will be removed}}
  // expected-note@Inputs/std-coroutine-exp-namespace.h:8 {{'coroutine_traits' declared here}}
  // expected-error@-3 {{call to deleted member function 'await_transform'}}
  // expected-note@-4 {{'await_transform' implicitly required by 'co_await' here}}
}

And then on line 3 we can just write -verify. And in Inputs/std-coroutine-exp-namespace.h itself, we don't need to write anything.
This keeps the test more "all in one place," which I think is more readable/understandable.

(Likewise throughout. I assume this will have a big effect on all these tests.)

This revision now requires changes to proceed.Dec 22 2021, 9:42 AM
urnathan updated this revision to Diff 396025.Dec 23 2021, 7:25 AM

Update expected-diag markers

urnathan marked an inline comment as done.Dec 23 2021, 7:25 AM
This revision is now accepted and ready to land.Jan 1 2022, 6:14 AM
This revision was landed with ongoing or failed builds.Jan 2 2022, 9:24 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJan 2 2022, 9:24 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript