aboutsummaryrefslogtreecommitdiff
path: root/gcc/doc
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2022-10-28 10:02:34 +0200
committerMartin Liska <mliska@suse.cz>2022-10-28 10:02:34 +0200
commit1eb021edb27e26f95cda63df121f6bc951647599 (patch)
tree7f132fded85bd7d05d81cd4c1227da2fd0c3c2d5 /gcc/doc
parent62e475bad0d668c432bb97113cbf73fa281b8b55 (diff)
parent0607307768b66a90e27c5bc91a247acc938f070e (diff)
downloadgcc-1eb021edb27e26f95cda63df121f6bc951647599.zip
gcc-1eb021edb27e26f95cda63df121f6bc951647599.tar.gz
gcc-1eb021edb27e26f95cda63df121f6bc951647599.tar.bz2
Merge branch 'master' into devel/sphinx
Diffstat (limited to 'gcc/doc')
-rw-r--r--gcc/doc/extend.texi77
-rw-r--r--gcc/doc/invoke.texi55
-rw-r--r--gcc/doc/makefile.texi10
3 files changed, 141 insertions, 1 deletions
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 3a1d4a5..48f3b9a 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -15750,6 +15750,83 @@ Load 32-bits from the @code{struct sk_buff} packet data pointed by the register
BPF Compile Once-Run Everywhere (CO-RE) support. Instruct GCC to generate CO-RE relocation records for any accesses to aggregate data structures (struct, union, array types) in @var{expr}. This builtin is otherwise transparent, the return value is whatever @var{expr} evaluates to. It is also overloaded: @var{expr} may be of any type (not necessarily a pointer), the return type is the same. Has no effect if @code{-mco-re} is not in effect (either specified or implied).
@end deftypefn
+@deftypefn {Built-in Function} unsigned int __builtin_preserve_field_info (@var{expr}, unsigned int @var{kind})
+BPF Compile Once-Run Everywhere (CO-RE) support. This builtin is used to
+extract information to aid in struct/union relocations. @var{expr} is
+an access to a field of a struct or union. Depending on @var{kind}, different
+information is returned to the program. A CO-RE relocation for the access in
+@var{expr} with kind @var{kind} is recorded if @code{-mco-re} is in effect.
+
+The following values are supported for @var{kind}:
+@table @var
+@item FIELD_BYTE_OFFSET = 0
+The returned value is the offset, in bytes, of the field from the
+beginning of the containing structure. For bitfields, the byte offset
+of the containing word.
+
+@item FIELD_BYTE_SIZE = 1
+The returned value is the size, in bytes, of the field. For bitfields,
+the size in bytes of the containing word.
+
+@item FIELD_EXISTENCE = 2
+The returned value is 1 if the field exists, 0 otherwise. Always 1 at
+compile time.
+
+@item FIELD_SIGNEDNESS = 3
+The returned value is 1 if the field is signed, 0 otherwise.
+
+@item FIELD_LSHIFT_U64 = 4
+@itemx FIELD_RSHIFT_U64 = 5
+The returned value is the number of bits of left- or right-shifting
+respectively needed in order to recover the original value of the field,
+after it has been loaded by a read of FIELD_BYTE_SIZE bytes into an
+unsigned 64-bit value. Primarily useful for reading bitfield values
+from structures which may change between kernel versions.
+
+@end table
+
+Note that the return value is a constant which is known at
+compile-time. If the field has a variable offset then
+FIELD_BYTE_OFFSET, FIELD_LSHIFT_U64 and FIELD_RSHIFT_U64 are not
+supported. Similarly, if the field has a variable size then
+FIELD_BYTE_SIZE, FIELD_LSHIFT_U64 and FIELD_RSHIFT_U64 are not
+supported.
+
+For example, __builtin_preserve_field_info can be used to reliably
+extract bitfield values from a structure which may change between
+kernel versions:
+
+@example
+struct S
+@{
+ short a;
+ int x:7;
+ int y:5;
+@};
+
+int
+read_y (struct S *arg)
+@{
+ unsigned long long val;
+ unsigned int offset = __builtin_preserve_field_info (arg->y, FIELD_BYTE_OFFSET);
+ unsigned int size = __builtin_presrve_field_info (arg->y, FIELD_BYTE_SIZE);
+
+ /* Read size bytes from arg + offset into val. */
+ bpf_probe_read (&val, size, arg + offset);
+
+ val <<= __builtin_preserve_field_info (arg->y, FIELD_LSHIFT_U64);
+
+ if (__builtin_preserve_field_info (arg->y, FIELD_SIGNEDNESS))
+ val = ((long long) val >> __builtin_preserve_field_info (arg->y, FIELD_RSHIFT_U64));
+ else
+ val >>= __builtin_preserve_field_info (arg->y, FIELD_RSHIFT_U64);
+
+ return val;
+@}
+
+@end example
+@end deftypefn
+
@node FR-V Built-in Functions
@subsection FR-V Built-in Functions
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index ed79440..f138db2 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -211,7 +211,8 @@ in the following sections.
-Wno-class-conversion -Wclass-memaccess @gol
-Wcomma-subscript -Wconditionally-supported @gol
-Wno-conversion-null -Wctad-maybe-unsupported @gol
--Wctor-dtor-privacy -Wno-delete-incomplete @gol
+-Wctor-dtor-privacy -Wdangling-reference @gol
+-Wno-delete-incomplete @gol
-Wdelete-non-virtual-dtor -Wno-deprecated-array-compare @gol
-Wdeprecated-copy -Wdeprecated-copy-dtor @gol
-Wno-deprecated-enum-enum-conversion -Wno-deprecated-enum-float-conversion @gol
@@ -3589,6 +3590,54 @@ public static member functions. Also warn if there are no non-private
methods, and there's at least one private member function that isn't
a constructor or destructor.
+@item -Wdangling-reference @r{(C++ and Objective-C++ only)}
+@opindex Wdangling-reference
+@opindex Wno-dangling-reference
+Warn when a reference is bound to a temporary whose lifetime has ended.
+For example:
+
+@smallexample
+int n = 1;
+const int& r = std::max(n - 1, n + 1); // r is dangling
+@end smallexample
+
+In the example above, two temporaries are created, one for each
+argument, and a reference to one of the temporaries is returned.
+However, both temporaries are destroyed at the end of the full
+expression, so the reference @code{r} is dangling. This warning
+also detects dangling references in member initializer lists:
+
+@smallexample
+const int& f(const int& i) @{ return i; @}
+struct S @{
+ const int &r; // r is dangling
+ S() : r(f(10)) @{ @}
+@};
+@end smallexample
+
+Member functions are checked as well, but only their object argument:
+
+@smallexample
+struct S @{
+ const S& self () @{ return *this; @}
+@};
+const S& s = S().self(); // s is dangling
+@end smallexample
+
+Certain functions are safe in this respect, for example @code{std::use_facet}:
+they take and return a reference, but they don't return one of its arguments,
+which can fool the warning. Such functions can be excluded from the warning
+by wrapping them in a @code{#pragma}:
+
+@smallexample
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdangling-reference"
+const T& foo (const T&) @{ @dots{} @}
+#pragma GCC diagnostic pop
+@end smallexample
+
+This warning is enabled by @option{-Wall}.
+
@item -Wdelete-non-virtual-dtor @r{(C++ and Objective-C++ only)}
@opindex Wdelete-non-virtual-dtor
@opindex Wno-delete-non-virtual-dtor
@@ -16422,6 +16471,10 @@ by this option.
@end table
+Note the enabled sanitizer options tend to increase a false-positive rate
+of selected warnings, most notably @option{-Wmaybe-uninitialized}.
+And thus we recommend to disable @option{-Werror}.
+
While @option{-ftrapv} causes traps for signed overflows to be emitted,
@option{-fsanitize=undefined} gives a diagnostic message.
This currently works only for the C family of languages.
diff --git a/gcc/doc/makefile.texi b/gcc/doc/makefile.texi
index fe0bbcd..5186c1c 100644
--- a/gcc/doc/makefile.texi
+++ b/gcc/doc/makefile.texi
@@ -135,6 +135,16 @@ Compares the results of stages 2 and 3. This ensures that the compiler
is running properly, since it should produce the same object files
regardless of how it itself was compiled.
+@item distclean-stage@var{N} (@var{N} = 1@dots{}4, profile, feedback)
+Wipe stage @var{N} and all the following ones.
+
+For example,
+@samp{make distclean-stage3} wipes stage 3 and all the following ones,
+so that another @command{make} then rebuilds them from scratch.
+This can be useful if you're doing changes where
+``bubbling'' the changes as described above is not sufficient,
+but a full @command{make restrap} isn't necessary either.
+
@item profiledbootstrap
Builds a compiler with profiling feedback information. In this case,
the second and third stages are named @samp{profile} and @samp{feedback},