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">; 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; + InGroup; 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/test/SemaCXX/ignored-reference-qualifiers-disabled.cpp =================================================================== --- /dev/null +++ clang/test/SemaCXX/ignored-reference-qualifiers-disabled.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 %s -std=c++11 -Wignored-qualifiers -Wno-ignored-reference-qualifiers -verify + +const int scalar_c(); // expected-warning{{'const' type qualifier on return type has no effect}} +volatile int scalar_v(); // expected-warning{{'volatile' type qualifier on return type has no effect}} +const volatile int scalar_cv(); // expected-warning{{'const volatile' type qualifiers on return type have no effect}} + +// no warnings expected below here, as we've disabled ignored-reference-qualifiers. +typedef int& IntRef; + +const IntRef ref_c(); +volatile IntRef ref_v(); +const volatile IntRef ref_cv(); + +template +class container { + using value_type = T; + using reference = value_type&; + reference get(); + const reference get() const; +}; Index: clang/test/SemaCXX/ignored-reference-qualifiers.cpp =================================================================== --- /dev/null +++ clang/test/SemaCXX/ignored-reference-qualifiers.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 %s -std=c++11 -Wignored-qualifiers -verify + +const int scalar_c(); // expected-warning{{'const' type qualifier on return type has no effect}} +volatile int scalar_v(); // expected-warning{{'volatile' type qualifier on return type has no effect}} +const volatile int scalar_cv(); // expected-warning{{'const volatile' type qualifiers on return type have no effect}} + +typedef int& IntRef; + +const IntRef ref_c(); // expected-warning{{'const' qualifier on reference type 'IntRef' (aka 'int &') has no effect}} +volatile IntRef ref_v(); // expected-warning{{'volatile' qualifier on reference type 'IntRef' (aka 'int &') has no effect}} +const volatile IntRef ref_cv(); /* expected-warning{{'const' qualifier on reference type 'IntRef' (aka 'int &') has no effect}} \ + expected-warning{{'volatile' qualifier on reference type 'IntRef' (aka 'int &') has no effect}} */ + +template +class container { + using value_type = T; + using reference = value_type&; + reference get(); + const reference get() const; // expected-warning{{'const' qualifier on reference type 'container::reference' (aka 'T &') has no effect}} +};