]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: Move -Wdangling-reference to -Wextra
authorMarek Polacek <polacek@redhat.com>
Thu, 1 Aug 2024 14:35:38 +0000 (10:35 -0400)
committerMarek Polacek <polacek@redhat.com>
Fri, 2 Aug 2024 18:42:17 +0000 (14:42 -0400)
Despite a number of mitigations (don't warn for std::span-like classes,
lambdas, adding [[gnu::no_dangling]], etc.), the warning still seems to
cause some grief.  Let's move the warning to -Wextra, then.

gcc/c-family/ChangeLog:

* c.opt (Wdangling-reference): Move from -Wall to -Wextra.

gcc/ChangeLog:

* doc/invoke.texi: Document that -Wdangling-reference is
enabled by -Wextra.

gcc/c-family/c.opt
gcc/doc/invoke.texi

index a52682d835ce969be841e5c201a7ebb1618e3845..979f17a7e3232c0c1eba891ae54f0951a0e9611f 100644 (file)
@@ -604,7 +604,7 @@ C ObjC C++ ObjC++ Joined RejectNegative UInteger Var(warn_dangling_pointer) Warn
 Warn for uses of pointers to auto variables whose lifetime has ended.
 
 Wdangling-reference
-C++ ObjC++ Var(warn_dangling_reference) Warning LangEnabledBy(C++ ObjC++, Wall)
+C++ ObjC++ Var(warn_dangling_reference) Warning LangEnabledBy(C++ ObjC++, Wextra)
 Warn when a reference is bound to a temporary whose lifetime has ended.
 
 Wdate-time
index 54ecd9a00eb4142b21e4532446164e641bb66567..0fe99ca8ef6e8868f60369f6329fe29599d89159 100644 (file)
@@ -3962,7 +3962,7 @@ that has a pointer data member and a trivial destructor.
 The warning can be disabled by using the @code{gnu::no_dangling} attribute
 (@pxref{C++ Attributes}).
 
-This warning is enabled by @option{-Wall}.
+This warning is enabled by @option{-Wextra}.
 
 @opindex Wdelete-non-virtual-dtor
 @opindex Wno-delete-non-virtual-dtor
@@ -6481,6 +6481,7 @@ name is still supported, but the newer name is more descriptive.)
 -Wcalloc-transposed-args
 -Wcast-function-type
 -Wclobbered
+-Wdangling-reference @r{(C++ only)}
 -Wdeprecated-copy @r{(C++ and Objective-C++ only)}
 -Wempty-body
 -Wenum-conversion @r{(only for C/ObjC)}