[clang] Warn about deprecated volatile-qualified return types (#137899)
The old codepath in GetFullTypeForDeclarator was under "if (not a class type)" so that it failed to warn for class types. Move the diagnostic outside of the "if" so that it warns in the proper situations. Fixes #133380 Co-authored-by: cor3ntin <corentinjabot@gmail.com>
This commit is contained in:
parent
98d68e49f7
commit
0b9c63dfe9
@ -509,6 +509,9 @@ Improvements to Clang's diagnostics
|
||||
- Clang now prints the namespace for an attribute, if any,
|
||||
when emitting an unknown attribute diagnostic.
|
||||
|
||||
- ``-Wvolatile`` now warns about volatile-qualified class return types
|
||||
as well as volatile-qualified scalar return types. Fixes #GH133380
|
||||
|
||||
- Several compatibility diagnostics that were incorrectly being grouped under
|
||||
``-Wpre-c++20-compat`` are now part of ``-Wc++20-compat``. (#GH138775)
|
||||
|
||||
@ -921,7 +924,8 @@ Improvements
|
||||
^^^^^^^^^^^^
|
||||
|
||||
Additional Information
|
||||
======================
|
||||
|
||||
===================
|
||||
|
||||
A wide variety of additional information is available on the `Clang web
|
||||
page <https://clang.llvm.org/>`_. The web page contains versions of the
|
||||
|
@ -5056,13 +5056,13 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
|
||||
S.Diag(DeclType.Loc, diag::err_func_returning_qualified_void) << T;
|
||||
} else
|
||||
diagnoseRedundantReturnTypeQualifiers(S, T, D, chunkIndex);
|
||||
|
||||
// C++2a [dcl.fct]p12:
|
||||
// A volatile-qualified return type is deprecated
|
||||
if (T.isVolatileQualified() && S.getLangOpts().CPlusPlus20)
|
||||
S.Diag(DeclType.Loc, diag::warn_deprecated_volatile_return) << T;
|
||||
}
|
||||
|
||||
// C++2a [dcl.fct]p12:
|
||||
// A volatile-qualified return type is deprecated
|
||||
if (T.isVolatileQualified() && S.getLangOpts().CPlusPlus20)
|
||||
S.Diag(DeclType.Loc, diag::warn_deprecated_volatile_return) << T;
|
||||
|
||||
// Objective-C ARC ownership qualifiers are ignored on the function
|
||||
// return type (by type canonicalization). Complain if this attribute
|
||||
// was written here.
|
||||
|
@ -356,7 +356,7 @@ namespace LValueToRValue {
|
||||
// - a non-volatile glvalue of literal type that refers to a non-volatile
|
||||
// temporary object whose lifetime has not ended, initialized with a
|
||||
// constant expression;
|
||||
constexpr volatile S f() { return S(); }
|
||||
constexpr volatile S f() { return S(); } // cxx20-warning {{volatile-qualified return type 'volatile S' is deprecated}}
|
||||
static_assert(f().i, ""); // expected-error {{constant expression}} expected-note {{read of volatile-qualified type}}
|
||||
static_assert(((volatile const S&&)(S)0).i, ""); // expected-error {{constant expression}} expected-note {{read of volatile-qualified type}}
|
||||
}
|
||||
|
@ -231,6 +231,13 @@ namespace DeprecatedVolatile {
|
||||
a = c = a;
|
||||
b += a;
|
||||
}
|
||||
|
||||
volatile struct amber jurassic();
|
||||
// cxx20-warning@-1 {{volatile-qualified return type 'volatile struct amber' is deprecated}}
|
||||
void trex(volatile short left_arm, volatile struct amber right_arm);
|
||||
// cxx20-warning@-1 {{volatile-qualified parameter type 'volatile short' is deprecated}}
|
||||
// cxx20-warning@-2 {{volatile-qualified parameter type 'volatile struct amber' is deprecated}}
|
||||
void fly(volatile struct pterosaur* pteranodon);
|
||||
}
|
||||
|
||||
namespace ArithConv {
|
||||
|
Loading…
x
Reference in New Issue
Block a user