Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-Wdeprecated-volatile doesn't handle class types correctly #39

Open
Quuxplusone opened this issue Sep 26, 2024 · 0 comments
Open

-Wdeprecated-volatile doesn't handle class types correctly #39

Quuxplusone opened this issue Sep 26, 2024 · 0 comments
Labels
c++20 clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer

Comments

@Quuxplusone
Copy link
Owner

https://godbolt.org/z/r9o1b9qM8
https://eel.is/c++draft/depr.volatile.type#3 gives this Annex C example:

volatile struct amber jurassic();                               // deprecated
void trex(volatile short left_arm, volatile short right_arm);   // deprecated
void fly(volatile struct pterosaur* pteranodon);                // OK

Clang trunk diagnoses the second line, but not the first. This is because the line of code that emits that volatile-return-type warning:

    // 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;

is incorrectly placed inside this conditional:

if ((T.getCVRQualifiers() || T->isAtomicType()) &&
    !(S.getLangOpts().CPlusPlus &&
      (T->isDependentType() || T->isRecordType()))) {

instead of outside, so it incorrectly fails to apply to volatile-qualified class types such as struct amber.

@Quuxplusone Quuxplusone added c++20 clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer labels Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++20 clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer
Projects
None yet
Development

No branches or pull requests

1 participant