1 # Copyright
(C
) 2005-2017 Free Software Foundation
, Inc.
3 # This
program is free software
; you can redistribute it and
/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation
; either version
3 of the License
, or
6 #
(at your option
) any later version.
8 # This
program is distributed in the hope that it will be useful
,
9 # but WITHOUT
ANY WARRANTY
; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License
for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with GCC
; see the file COPYING3.
If not see
15 #
<http
://www.gnu.org
/licenses
/>.
17 # This file contains a
set of test that check that gcc options are
18 # documented in
--help
, and that the various
--help
* options work.
23 # These tests don
't run runtest_file_p consistently if it
24 # doesn't
return the same
values, so disable parallelization
25 # of this
*.exp file. The first parallel runtest to reach
26 # this will run all the tests serially.
27 if ![gcc_parallel_test_run_p help
] {
30 gcc_parallel_test_enable
0
32 # GCC breaks up
--help output into lines at most $COLUMNS characters
33 # wide
(or
80 when COLUMNS is not defined
), set the COLUMNS environment
34 #
variable to a value large enough to prevent this
(and restore it when
38 if [ info exists env
(COLUMNS
) ] {
39 set prev_columns $env
(COLUMNS
)
44 # Document
--version. Ideally
, there should be no undocumented switches
46 check_for_options c
"--help" "--version" "This option lacks documentation" ""
48 # Output from different subprocesses should not be intermingled
49 #
(we check
for some patterns that could be seen with a missing
51 check_for_options c
"-v --help" "" {
52 [^
\n]The following options
53 -Wconversion
[^
\n]*lacks documentation
57 # There are still undocumented switches in
-v
--help.
58 check_for_options c
"-v --help" "" "This option lacks documentation" "xfail"
60 # Check whether multiline conversion in optc
-gen is broken.
61 check_for_options c
"-v --help" "" {are likely to\n -std} ""
63 # Try various
--help
= classes and qualifiers.
64 check_for_options c
"--help=optimizers" "-O" " -g " ""
65 check_for_options c
"--help=params" "maximum number of" "-Wunsafe-loop-optimizations" ""
66 check_for_options c
"--help=C" "-ansi" "-gnatO" ""
67 check_for_options c
{--help
=C
++} {-std
=c\
+\
+} "-gnatO" ""
68 check_for_options c
"--help=common" "-dumpbase" "-gnatO" ""
69 check_for_options c
"--help=undocumented" "This option lacks documentation" "" ""
71 # Undocumented flags are not yet consistently marked as such.
72 check_for_options c
"--help=^undocumented" "-Wall" "This option lacks documentation" "xfail"
74 # Try some
--help
=* examples from the manual.
75 check_for_options c
"--help=target,undocumented" "" "" ""
76 check_for_options c
"--help=target,optimizers" "" "" ""
77 check_for_options c
"--help=warnings,^joined,^undocumented" "" "" ""
78 check_for_options c
"-Q -O2 --help=optimizers" {
80 -ftree
-loop
-vectorize
[^
\n]*disabled
82 check_for_options c
"-Q -O3 --help=optimizers" {
84 -ftree
-loop
-vectorize
[^
\n]*enabled
86 # Try repeated
--help
=.
87 check_for_options c
"--help=params --help=optimizers" {
92 # Ensure PR
37805 is fixed.
93 # Specify patterns
(arguments
3 and later
) that match option names
94 # at the beginning of the line and not when they are referenced by
95 # some other options later
on.
96 check_for_options c
"--help=joined" \
97 "^ +-Wformat=" "^ +-fstrict-prototype" ""
98 check_for_options c
"--help=separate" \
99 "^ +-MF" "^ +-fstrict-prototype" ""
100 check_for_options c
"--help=warnings,joined" \
101 "^ +-Wformat=" "^ +-Wtrigraphs" ""
102 check_for_options c
"--help=warnings,^joined" \
103 "^ +-Wtrigraphs" "^ +-Wformat=" ""
104 check_for_options c
"--help=joined,separate" \
106 check_for_options c
"--help=^joined,separate" \
108 check_for_options c
"--help=joined,^separate" \
110 check_for_options c
"--help=joined,undocumented" "" "" ""
112 # Check to make sure the description
for every option is a complete
113 # sentence ending in a period. This matters not just
for consistency
114 # but also because other sentences may be appended to it by the help
115 # subsystem.
Do this one help class at a time to make it easier to
116 # find the source a failure.
118 foreach cls
{ "ada" "c" "c++" "fortran" "go" \
119 "optimizers" "param" "target" "warnings" } {
121 check_for_options c
"--help=$cls" "" "^ +-.*\[^:.\]$" ""
124 # Listing only excludes gives empty results.
125 check_for_options c
"--help=^joined,^separate" "" "" ""
127 if [ info exists prev_columns
] {
128 # Reset the enviroment
variable to its oriuginal value.
129 set env
(COLUMNS
) $prev_columns
131 # Remove the
variable from the environment
if it didn
't exist
132 # to begin with to avoid affecting subsequent tests.
133 array unset env COLUMNS
136 gcc_parallel_test_enable 1