[PATCH] D107292: [clang] adds warning to alert user when they use alternative tokens as references

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 3 10:58:53 PDT 2021


rsmith added a comment.

We should also warn on:

- `and` or `bitand` used as a ref-qualifier in a member function declaration
- `xor` used to declare a block pointer type or block pointer literal
- `bitand` used as address-of and `and` used to form a GNU address-of-label
- `compl` used to name a destructor

Of these, I think it's somewhat important to handle ref-qualifiers and probably block pointer types at around the same time that this patch lands (though it doesn't need to be part of this patch) for consistency among "type operators".



================
Comment at: clang/include/clang/Basic/DiagnosticParseKinds.td:1551
+def warn_declare_references_with_symbols : Warning<
+  "use '%select{&|&&}0' when declaring %select{lvalue|rvalue and forwarding}1 references">,
+  InGroup<DiagGroup<"declare-references-with-symbols">>;
----------------
Drop the "and forwarding" part; a forwarding reference is a kind of rvalue reference, and distinguishing them here will lead to confusion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107292



More information about the cfe-commits mailing list