[llvm-branch-commits] [clang] [clang] Implement instantiation context note for checking template parameters (PR #126088)

Aaron Ballman via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Feb 19 11:31:38 PST 2025


================
@@ -1018,9 +1019,9 @@ namespace cwg62 { // cwg62: 2.9
   struct A {
     struct { int n; } b;
   };
-  template<typename T> struct X {};
-  template<typename T> T get() { return get<T>(); }
-  template<typename T> int take(T) { return 0; }
+  template<typename T> struct X {}; // cxx98-note 6{{template parameter is declared here}}
----------------
AaronBallman wrote:

> My concern is not about the bookmarks though, is about the way the tests are written here, checking the whole
diagnostic sequence, but without actually checking it, and without any kind of automated update.

I'm not certain I understand the concern then. The request is to do something like:
```
template<typename T> struct X {}; // #template_struct_X
...
... // expected-warning {{yada yada}}
    // expected-note@#template_struct_X {{declared here}}
...
... // expected-warning {{yada yada}} \
    // expected-note@#template_struct_X {{declared here}} \
    // expected-error {{a different yada on the same line}} \
    // expected-note@#template_struct_X {{declared here}}
```
instead of doing:
```
template<typename T> struct X {}; // expected-note 3 {{declared here}}
...
... // expected-warning {{yada yada}}
...
... // expected-warning {{yada yada}} \
    // expected-error {{a different yada on the same line}}
```

so either way it is actually checking the whole diagnostic sequence, just that with bookmarks it's easier to tell which warnings/errors generate what notes. And we've never had a way to automatically update `-verify` tests. We do for some kinds of `FileCheck` tests, but that can be contentious because of how easy it is to generate the test updates, bugs and all. (I'm not opposed to having tooling which helps with diagnostic changes; upgrading warnings to errors is a prime example of something that could hopefully be made easier.)

https://github.com/llvm/llvm-project/pull/126088


More information about the llvm-branch-commits mailing list