[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 10:59:46 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:

> Why though? These notes are not particularly relevant for a DR test.

It's kind of subjective. The goal is to ensure that the DR is implemented properly and that can mean ensuring the diagnostics make sense. And "diagnostics make sense" is the subjective bit -- it's not always clear why there are 6 notes on a single line; that can hide bugs. For example, I've certainly had bugs where a note is accidentally duplicated.

Using bookmarks to keep groups of diagnostics together is one way to help ensure it's clear what diagnostics are issued and why, and for DR tests specifically, these are the critical tests for the functionality change. I think it's fine to be a bit more relaxed in Sema/Parser/etc.

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


More information about the llvm-branch-commits mailing list