c.opt (Wmissing-attributes): Clean up doc string.
authorSandra Loosemore <sandra@codesourcery.com>
Mon, 25 Feb 2019 20:38:42 +0000 (15:38 -0500)
committerSandra Loosemore <sandra@gcc.gnu.org>
Mon, 25 Feb 2019 20:38:42 +0000 (15:38 -0500)
2019-02-25  Sandra Loosemore  <sandra@codesourcery.com>
    Martin Sebor  <msebor@gmail.com>

gcc/
* c-family/c.opt (Wmissing-attributes): Clean up doc string.
* common.opt (Wattribute-alias): Likewise.
* doc/invoke.texi (Option Summary): List general form of
-Wattribute-alias=.  List positive form of -Wmissing-attributes.
(-Wmissing-attributes): Invert entry, rewrite and correct default.
Add cross-references.
(-Wattribute-alias): Rewrite and correct default.  Mention
considered attributes (same as for -Wmissing-attributes).

Co-Authored-By: Martin Sebor <msebor@gmail.com>
From-SVN: r269196

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

index 6ed6890..b146480 100644 (file)
@@ -1,3 +1,15 @@
+2019-02-25  Sandra Loosemore  <sandra@codesourcery.com>
+           Martin Sebor  <msebor@gmail.com>
+
+       * c-family/c.opt (Wmissing-attributes): Clean up doc string.
+       * common.opt (Wattribute-alias): Likewise.
+       * doc/invoke.texi (Option Summary): List general form of
+       -Wattribute-alias=.  List positive form of -Wmissing-attributes.
+       (-Wmissing-attributes): Invert entry, rewrite and correct default.
+       Add cross-references.
+       (-Wattribute-alias): Rewrite and correct default.  Mention
+       considered attributes (same as for -Wmissing-attributes).
+
 2019-02-25  Paul A. Clarke  <pc@us.ibm.com>
 
 [gcc]
index 88c72c5..962973a 100644 (file)
@@ -818,7 +818,7 @@ Warn on primary template declaration.
 Wmissing-attributes
 C ObjC C++ ObjC++ Var(warn_missing_attributes) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall)
 Warn about declarations of entities that may be missing attributes
-that related entities have been declared with it.
+that related entities have been declared with.
 
 Wmissing-format-attribute
 C ObjC C++ ObjC++ Warning Alias(Wsuggest-attribute=format)
index 295cb1f..fb42e18 100644 (file)
@@ -552,11 +552,11 @@ Warn about inappropriate attribute usage.
 
 Wattribute-alias
 Common Alias(Wattribute_alias=, 1, 0) Warning
-Warn about type safety and similar errors and mismatches in attribute alias and related.
+Warn about type safety and similar errors and mismatches in declarations with alias attributes.
 
 Wattribute-alias=
 Common Joined RejectNegative UInteger Var(warn_attribute_alias) Init(1) Warning IntegerRange(0, 2)
-Warn about type safety and similar errors and mismatches in attribute alias and related.
+Warn about type safety and similar errors and mismatches in declarations with alias attributes.
 
 Wcannot-profile
 Common Var(warn_cannot_profile) Init(1) Warning
index 11efc42..dedf3c4 100644 (file)
@@ -288,7 +288,7 @@ Objective-C and Objective-C++ Dialects}.
 -Walloc-zero  -Walloc-size-larger-than=@var{byte-size} @gol
 -Walloca  -Walloca-larger-than=@var{byte-size} @gol
 -Wno-aggressive-loop-optimizations  -Warray-bounds  -Warray-bounds=@var{n} @gol
--Wno-attributes  -Wno-attribute-alias @gol
+-Wno-attributes  -Wattribute-alias=@var{n}  @gol
 -Wbool-compare  -Wbool-operation @gol
 -Wno-builtin-declaration-mismatch @gol
 -Wno-builtin-macro-redefined  -Wc90-c99-compat  -Wc99-c11-compat @gol
@@ -322,7 +322,7 @@ Objective-C and Objective-C++ Dialects}.
 -Winvalid-pch  -Wlarger-than=@var{byte-size} @gol
 -Wlogical-op  -Wlogical-not-parentheses  -Wlong-long @gol
 -Wmain  -Wmaybe-uninitialized  -Wmemset-elt-size  -Wmemset-transposed-args @gol
--Wmisleading-indentation  -Wno-missing-attributes  -Wmissing-braces @gol
+-Wmisleading-indentation  -Wmissing-attributes  -Wmissing-braces @gol
 -Wmissing-field-initializers  -Wmissing-format-attribute @gol
 -Wmissing-include-dirs  -Wmissing-noreturn  -Wmissing-profile @gol
 -Wno-multichar  -Wmultistatement-macros  -Wnonnull  -Wnonnull-compare @gol
@@ -5056,7 +5056,7 @@ about the layout of the file that the directive references.
 
 This warning is enabled by @option{-Wall} in C and C++.
 
-@item -Wno-missing-attributes
+@item -Wmissing-attributes
 @opindex Wmissing-attributes
 @opindex Wno-missing-attributes
 Warn when a declaration of a function is missing one or more attributes
@@ -5064,10 +5064,10 @@ that a related function is declared with and whose absence may adversely
 affect the correctness or efficiency of generated code.  For example,
 the warning is issued for declarations of aliases that use attributes
 to specify less restrictive requirements than those of their targets.
-This typically represents a potential optimization oportunity rather
-than a hidden bug.  The @option{-Wattribute-alias} option controls warnings
-issued for mismatches between declarations of aliases and their targets
-that might be indicative of code generation bugs.
+This typically represents a potential optimization opportunity.
+By contrast, the @option{-Wattribute-alias=2} option controls warnings
+issued when the alias is more restrictive than the target, which could
+lead to incorrect code generation.
 Attributes considered include @code{alloc_align}, @code{alloc_size},
 @code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc},
 @code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure},
@@ -5080,6 +5080,13 @@ or @code{nonnull} is declared without it.  Attributes @code{deprecated},
 @code{error}, and @code{warning} suppress the warning.
 (@pxref{Function Attributes}).
 
+You can use the @code{copy} attribute to apply the same
+set of attributes to a declaration as that on another declaration without
+explicitly enumerating the attributes. This attribute can be applied
+to declarations of functions (@pxref{Common Function Attributes}),
+variables (@pxref{Common Variable Attributes}), or types
+(@pxref{Common Type Attributes}).
+
 @option{-Wmissing-attributes} is enabled by @option{-Wall}.
 
 For example, since the declaration of the primary function template
@@ -6107,7 +6114,6 @@ false positives and is deactivated by default.
 Warn about declarations using the @code{alias} and similar attributes whose
 target is incompatible with the type of the alias.
 @xref{Function Attributes,,Declaring Attributes of Functions}.
-The @option{-Wattribute-alias=1} is  enabled by @option{-Wall}.
 
 @table @gcctabopt
 @item -Wattribute-alias=1
@@ -6116,13 +6122,26 @@ incompatibilities between the type of the alias declaration and that of its
 target.  Such incompatibilities are typically indicative of bugs.
 
 @item -Wattribute-alias=2
-At this level @option{-Wattribute-alias} also diagnoses mismatches between
-the set of attributes of the alias declaration and the attributes applied
-to its target.  Although in some cases such mismatches may indicate bugs,
-in other cases they may be benign and could be resolved simply by adding
-the missing attribute to the target.
+
+At this level @option{-Wattribute-alias} also diagnoses cases where
+the attributes of the alias declaration are more restrictive than the
+attributes applied to its target.  These mismatches can potentially
+result in incorrect code generation.  In other cases they may be
+benign and could be resolved simply by adding the missing attribute to
+the target.  For comparison, see the @option{-Wmissing-attributes}
+option, which controls diagnostics when the alias declaration is less
+restrictive than the target, rather than more restrictive.
+
+Attributes considered include @code{alloc_align}, @code{alloc_size},
+@code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc},
+@code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure},
+@code{returns_nonnull}, and @code{returns_twice}.
 @end table
 
+@option{-Wattribute-alias} is equivalent to @option{-Wattribute-alias=1}.
+This is the default.  You can disable these warnings with either
+@option{-Wno-attribute-alias} or @option{-Wattribute-alias=0}.
+
 @item -Wbool-compare
 @opindex Wno-bool-compare
 @opindex Wbool-compare