[clang] [Clang] Correct diagnostic notes for C++11 range-based for statements with invalid iterator types (PR #201461)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 22 08:02:04 PDT 2026


================
@@ -33,6 +33,36 @@ struct OverloadedStar {
   T operator*();
 };
 
+struct NonComparableIterator {
+  struct iterator {
+    bool operator!=(iterator) const = delete; // expected-note {{candidate function has been explicitly deleted}}
+    Data operator*() const;
+    iterator operator++() const;
+  };
+  iterator begin(); // expected-note {{selected 'begin' function with iterator type 'iterator'}}
+  iterator end();
+};
+
+struct NonIncrementableIterator {
+  struct iterator {
+    bool operator!=(iterator) const;
+    Data operator*() const;
+    iterator operator++() const = delete; // expected-note {{candidate function has been explicitly deleted}}
----------------
erichkeane wrote:

These diagnostics are unfortunately REALLY difficult to follow.  It would have been much nicer to use the bookmarking feature to put them in order when they are reported.

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


More information about the cfe-commits mailing list