[clang] [clang] Warn about deprecated volatile-qualified return types (PR #137899)

Mariya Podchishchaeva via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 30 01:58:24 PDT 2025


================
@@ -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;
----------------
Fznamznon wrote:

I see there is another place that issues `warn_deprecated_volatile_return` in `Sema::CheckFunctionReturnType`. I wonder why doesn't it suffice? 

https://github.com/llvm/llvm-project/pull/137899


More information about the cfe-commits mailing list