[PATCH] D139570: Add -Wreturn-local-addr, GCC alias for -Wreturn-stack-address

Adrian Dole via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 6 13:46:23 PST 2023


adriandole updated this revision to Diff 486980.
adriandole added a comment.

Add test and release note.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139570/new/

https://reviews.llvm.org/D139570

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/test/SemaCXX/return-stack-addr-2.cpp


Index: clang/test/SemaCXX/return-stack-addr-2.cpp
===================================================================
--- clang/test/SemaCXX/return-stack-addr-2.cpp
+++ clang/test/SemaCXX/return-stack-addr-2.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -std=c++11 -Wno-return-stack-address -Wreturn-local-addr %s
 
 namespace PR26599 {
 template <typename>
Index: clang/include/clang/Basic/DiagnosticGroups.td
===================================================================
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -413,6 +413,8 @@
 def DanglingInitializerList : DiagGroup<"dangling-initializer-list">;
 def DanglingGsl : DiagGroup<"dangling-gsl">;
 def ReturnStackAddress : DiagGroup<"return-stack-address">;
+// Name of this warning in GCC
+def : DiagGroup<"return-local-addr", [ReturnStackAddress]>;
 def Dangling : DiagGroup<"dangling", [DanglingField,
                                       DanglingInitializerList,
                                       DanglingGsl,
Index: clang/docs/ReleaseNotes.rst
===================================================================
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -439,6 +439,7 @@
   ``#pragma clang __debug sloc_usage`` can also be used to request this report.
 - Clang no longer permits the keyword 'bool' in a concept declaration as a
   concepts-ts compatibility extension.
+- Add ``-Wreturn-local-addr``, a GCC alias for ``-Wreturn-stack-address``.
 
 Non-comprehensive list of changes in this release
 -------------------------------------------------


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139570.486980.patch
Type: text/x-patch
Size: 1698 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230106/8c5fd98a/attachment-0001.bin>


More information about the cfe-commits mailing list