[PATCH] D107125: [Diagnostic] Split 'qualifier on reference type has no effect' out into a new flag
Luna Kirkby via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 4 16:45:33 PDT 2021
lunasorcery updated this revision to Diff 364289.
lunasorcery added a comment.
Ah, that's much cleaner! I hadn't realized the test framework could do that.
I've updated the diff accordingly - your example works perfectly, so I've taken that and ditched the now-unnecessary other test.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D107125/new/
https://reviews.llvm.org/D107125
Files:
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/test/SemaCXX/ignored-reference-qualifiers-disabled.cpp
Index: clang/test/SemaCXX/ignored-reference-qualifiers-disabled.cpp
===================================================================
--- /dev/null
+++ clang/test/SemaCXX/ignored-reference-qualifiers-disabled.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 %s -std=c++11 -Wignored-qualifiers -Wno-ignored-reference-qualifiers -verify=both
+// RUN: %clang_cc1 %s -std=c++11 -Wignored-qualifiers -verify=both,qual
+
+const int scalar_c(); // both-warning{{'const' type qualifier on return type has no effect}}
+volatile int scalar_v(); // both-warning{{'volatile' type qualifier on return type has no effect}}
+const volatile int scalar_cv(); // both-warning{{'const volatile' type qualifiers on return type have no effect}}
+
+typedef int& IntRef;
+
+const IntRef ref_c(); // qual-warning{{'const' qualifier on reference type 'IntRef' (aka 'int &') has no effect}}
+volatile IntRef ref_v(); // qual-warning{{'volatile' qualifier on reference type 'IntRef' (aka 'int &') has no effect}}
+const volatile IntRef ref_cv(); // qual-warning{{'const' qualifier on reference type 'IntRef' (aka 'int &') has no effect}} \
+ qual-warning{{'volatile' qualifier on reference type 'IntRef' (aka 'int &') has no effect}}
+
+template<typename T>
+class container {
+ using value_type = T;
+ using reference = value_type&;
+ reference get();
+ const reference get() const; // qual-warning{{'const' qualifier on reference type 'container::reference' (aka 'T &') has no effect}}
+};
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===================================================================
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -5733,7 +5733,7 @@
"'%0' qualifier on function type %1 has unspecified behavior">;
def warn_typecheck_reference_qualifiers : Warning<
"'%0' qualifier on reference type %1 has no effect">,
- InGroup<IgnoredQualifiers>;
+ InGroup<IgnoredReferenceQualifiers>;
def err_typecheck_invalid_restrict_not_pointer : Error<
"restrict requires a pointer or reference (%0 is invalid)">;
def err_typecheck_invalid_restrict_not_pointer_noarg : Error<
Index: clang/include/clang/Basic/DiagnosticGroups.td
===================================================================
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -400,7 +400,8 @@
def InfiniteRecursion : DiagGroup<"infinite-recursion">;
def PureVirtualCallFromCtorDtor: DiagGroup<"call-to-pure-virtual-from-ctor-dtor">;
def GNUImaginaryConstant : DiagGroup<"gnu-imaginary-constant">;
-def IgnoredQualifiers : DiagGroup<"ignored-qualifiers">;
+def IgnoredReferenceQualifiers : DiagGroup<"ignored-reference-qualifiers">;
+def IgnoredQualifiers : DiagGroup<"ignored-qualifiers", [IgnoredReferenceQualifiers]>;
def : DiagGroup<"import">;
def GNUIncludeNext : DiagGroup<"gnu-include-next">;
def IncompatibleMSStruct : DiagGroup<"incompatible-ms-struct">;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107125.364289.patch
Type: text/x-patch
Size: 2991 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210804/398fe7a6/attachment.bin>
More information about the cfe-commits
mailing list