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

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 2 10:45:47 PDT 2021


aaron.ballman added inline comments.


================
Comment at: clang/include/clang/Basic/DiagnosticParseKinds.td:1552
+  "use '%select{&|&&}0' when declaring %select{lvalue|rvalue and forwarding}1 references">,
+  InGroup<DiagGroup<"declare-references-with-symbols">>, DefaultWarn;
+
----------------
Pretty sure you don't need `DefaultWarn` here (I think you'd use that for warnings that are off by default, like ones spelled with `Extension` instead of `Warning` or `ExtWarn`).


================
Comment at: clang/lib/Parse/ParseDecl.cpp:5847-5849
+        constexpr int AmpAmp = 1;
+        Diag(Loc, diag::warn_declare_references_with_symbols)
+            << AmpAmp << AmpAmp;
----------------
For consistency with the `Lvalue` case above.


================
Comment at: clang/test/Parser/warn-declare-references-with-symbols.cpp:2
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -Wdeclare-references-with-symbols -verify %s
+
----------------
cjdb wrote:
> I'm pretty confident there's a lit way for me to test specific lines with specific C++ modes, but I can't find it :(
Are you thinking of `-verify=prefix` and `// prefix-warning {{whatever}}` combinations?


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