1# Copyright (C) 2005-2018 Free Software Foundation, Inc. 2 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. 7# 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. 12# 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/>. 16 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. 19 20load_lib options.exp 21load_lib gcc-defs.exp 22 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. 27if ![gcc_parallel_test_run_p help] { 28 return 29} 30gcc_parallel_test_enable 0 31 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 35# done). 36global env 37 38if [ info exists env(COLUMNS) ] { 39 set prev_columns $env(COLUMNS) 40} 41 42set env(COLUMNS) 1024 43 44# Document --version. Ideally, there should be no undocumented switches 45# in --help. 46check_for_options c "--help" "--version" "This option lacks documentation" "" 47 48# Output from different subprocesses should not be intermingled 49# (we check for some patterns that could be seen with a missing 50# fflush in gcc.c). 51check_for_options c "-v --help" "" { 52[^\n]The following options 53-Wconversion[^\n]*lacks documentation 54" -g " 55} "" 56 57# There are still undocumented switches in -v --help. 58check_for_options c "-v --help" "" "This option lacks documentation" "xfail" 59 60# Check whether multiline conversion in optc-gen is broken. 61check_for_options c "-v --help" "" {are likely to\n -std} "" 62 63# Try various --help= classes and qualifiers. 64check_for_options c "--help=optimizers" "-O" " -g " "" 65check_for_options c "--help=params" "maximum number of" "-Wunsafe-loop-optimizations" "" 66check_for_options c "--help=C" "-ansi" "-gnatO" "" 67check_for_options c {--help=C++} {-std=c\+\+} "-gnatO" "" 68check_for_options c "--help=common" "-dumpbase" "-gnatO" "" 69check_for_options c "--help=undocumented" "This option lacks documentation" "" "" 70 71# Undocumented flags are not yet consistently marked as such. 72check_for_options c "--help=^undocumented" "-Wall" "This option lacks documentation" "xfail" 73 74# Try some --help=* examples from the manual. 75check_for_options c "--help=target,undocumented" "" "" "" 76check_for_options c "--help=target,optimizers" "" "" "" 77check_for_options c "--help=warnings,^joined,^undocumented" "" "" "" 78check_for_options c "-Q -O2 --help=optimizers" { 79-O 80-ftree-loop-vectorize[^\n]*disabled 81} " -g " "" 82check_for_options c "-Q -O3 --help=optimizers" { 83-O 84-ftree-loop-vectorize[^\n]*enabled 85} " -g " "" 86# Try repeated --help=. 87check_for_options c "--help=params --help=optimizers" { 88maximum number of 89-O 90} "" "" 91 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. 96check_for_options c "--help=joined" \ 97 "^ +-Wformat=" "^ +-fstrict-prototype" "" 98check_for_options c "--help=separate" \ 99 "^ +-MF" "^ +-fstrict-prototype" "" 100check_for_options c "--help=warnings,joined" \ 101 "^ +-Wformat=" "^ +-Wtrigraphs" "" 102check_for_options c "--help=warnings,^joined" \ 103 "^ +-Wtrigraphs" "^ +-Wformat=" "" 104check_for_options c "--help=joined,separate" \ 105 "^ +-I" "" "" 106check_for_options c "--help=^joined,separate" \ 107 "^ +--param " "" "" 108check_for_options c "--help=joined,^separate" \ 109 "^ +--help=" "" "" 110check_for_options c "--help=joined,undocumented" "" "" "" 111 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. 117 118foreach cls { "ada" "c" "c++" "fortran" "go" \ 119 "optimizers" "param" "target" "warnings" } { 120 121 check_for_options c "--help=$cls" "" "^ +-.*\[^:.\]$" "" 122} 123 124# Listing only excludes gives empty results. 125check_for_options c "--help=^joined,^separate" "" "" "" 126 127if [ info exists prev_columns ] { 128 # Reset the enviroment variable to its oriuginal value. 129 set env(COLUMNS) $prev_columns 130} else { 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 134} 135 136gcc_parallel_test_enable 1 137