| 1 |
# Copyright (C) 1997-2025 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 |
# Prune messages from gcc that aren't useful. |
| 18 |
|
| 19 |
load_lib multiline.exp |
| 20 |
|
| 21 |
# Add options to TEST_ALWAYS_FLAGS so that diagnostics have the expected output |
| 22 |
# format. Note: You should not normally need to add more options here. If you |
| 23 |
# have made a change to the default diagnostic output format and are wanting to |
| 24 |
# undo that in the testsuite here, then please update the handling of |
| 25 |
# -fdiagnostics-plain-output in opts-common.c instead. |
| 26 |
|
| 27 |
if ![info exists TEST_ALWAYS_FLAGS] { |
| 28 |
set TEST_ALWAYS_FLAGS "" |
| 29 |
} |
| 30 |
set TEST_ALWAYS_FLAGS "-fdiagnostics-plain-output $TEST_ALWAYS_FLAGS" |
| 31 |
|
| 32 |
proc prune_gcc_output { text } { |
| 33 |
global srcdir |
| 34 |
|
| 35 |
#send_user "Before:$text\n" |
| 36 |
|
| 37 |
# Handle any freeform regexps. |
| 38 |
set text [handle-dg-regexps $text] |
| 39 |
|
| 40 |
# Remove Windows .exe suffix |
| 41 |
regsub -all "(as|cc1|cc1plus|collect2|f951|ld|lto-wrapper)\.exe?:" $text {\1:} text |
| 42 |
|
| 43 |
regsub -all "(^|\n)(\[^\n\]*: \[iI\]|I)n ((static member |lambda )?function|member|method|(copy )?constructor|destructor|instantiation|substitution|program|subroutine|block-data)\[^\n\]*" $text "" text |
| 44 |
regsub -all "(^|\n)\[^\n\]*(: )?At (top level|global scope):\[^\n\]*" $text "" text |
| 45 |
regsub -all "(^|\n)\[^\n\]*: (recursively )?required \[^\n\]*" $text "" text |
| 46 |
regsub -all "(^|\n)\[^\n\]*: . skipping \[0-9\]* instantiation contexts \[^\n\]*" $text "" text |
| 47 |
regsub -all "(^|\n)\[^\n\]*: in .constexpr. expansion \[^\n\]*" $text "" text |
| 48 |
regsub -all "(^|\n)\[^\n\]*: in requirements \[^\n\]*" $text "" text |
| 49 |
regsub -all "(^|\n) inlined from \[^\n\]*" $text "" text |
| 50 |
regsub -all "(^|\n)\[^\n\]*: error: ld returned \[^\n\]*" $text "" text |
| 51 |
regsub -all "(^|\n)\[^\n\]*: re(compiling|linking)\[^\n\]*" $text "" text |
| 52 |
regsub -all "(^|\n)Please submit.*instructions\[^\n\]*" $text "" text |
| 53 |
regsub -all "(^|\n)\[0-9\]\[0-9\]* errors\." $text "" text |
| 54 |
regsub -all "(^|\n)Preprocessed.*bugreport\[^\n\]*" $text "" text |
| 55 |
|
| 56 |
# Diagnostic inclusion stack |
| 57 |
regsub -all "(^|\n)(In file)?\[ \]+included from \[^\n\]*" $text "" text |
| 58 |
regsub -all "(^|\n)\[ \]+from \[^\n\]*" $text "" text |
| 59 |
regsub -all "(^|\n)(In|of) module( \[^\n \]*,)? imported at \[^\n\]*" $text "" text |
| 60 |
|
| 61 |
global prune_notes |
| 62 |
if { $prune_notes } { |
| 63 |
# Ignore informational notes. |
| 64 |
regsub -all "(^|\n)\[^\n\]*: note: \[^\n\]*" $text "" text |
| 65 |
} |
| 66 |
|
| 67 |
# Ignore harmless -fpic warnings. |
| 68 |
regsub -all "(^|\n)\[^\n\]*: warning: -f(pic|PIC) ignored for target\[^\n\]*" $text "" text |
| 69 |
regsub -all "(^|\n)\[^\n\]*: warning: -f(pic|PIC)( and -fpic are| is)? not supported\[^\n\]*" $text "" text |
| 70 |
|
| 71 |
# Ignore errata warning from IA64 assembler. |
| 72 |
regsub -all "(^|\n)\[^\n\]*: Additional NOP may be necessary to workaround Itanium processor A/B step errata" $text "" text |
| 73 |
regsub -all "(^|\n)\[^\n*\]*: Assembler messages:\[^\n\]*" $text "" text |
| 74 |
|
| 75 |
# Ignore harmless VTA note. |
| 76 |
regsub -all "(^|\n)\[^\n\]*: note: variable tracking size limit exceeded with -fvar-tracking-assignments, retrying without\[^\n\]*" $text "" text |
| 77 |
|
| 78 |
# It would be nice to avoid passing anything to gcc that would cause it to |
| 79 |
# issue these messages (since ignoring them seems like a hack on our part), |
| 80 |
# but that's too difficult in the general case. For example, sometimes |
| 81 |
# you need to use -B to point gcc at crt0.o, but there are some targets |
| 82 |
# that don't have crt0.o. |
| 83 |
regsub -all "(^|\n)\[^\n\]*file path prefix \[^\n\]* never used" $text "" text |
| 84 |
regsub -all "(^|\n)\[^\n\]*linker input file unused since linking not done" $text "" text |
| 85 |
|
| 86 |
# Ideally the tests would indicate that executable stacks were needed |
| 87 |
# to the linker. But the option for that varies and may not even exist |
| 88 |
# on some targets. So we're stuck pruning the warning. |
| 89 |
regsub -all "(^|\n)(\[^\n\]*: warning:\[^\n\]*requires executable stack\[^\n\]*\n?)+" $text "\\1" text |
| 90 |
|
| 91 |
# Ignore harmless warnings from Xcode 3.2.x. |
| 92 |
regsub -all "(^|\n)\[^\n\]*ld: warning: can't add line info to anonymous symbol\[^\n\]*" $text "" text |
| 93 |
regsub -all "(^|\n)\[^\n\]*warning: DWARFDebugInfoEntry::AppendDependants\[^\n\]*AT_\[^\n\]*FORM_ref4\[^\n\]*" $text "" text |
| 94 |
regsub -all "(^|\n)\[^\n\]*warning:\[^\n\]*TAG_variable: AT_location\[^\n\]*didn't have valid function low pc\[^\n\]*" $text "" text |
| 95 |
|
| 96 |
# Ignore harmless warnings from Xcode 4.0. |
| 97 |
regsub -all "(^|\n)\[^\n\]*ld: warning: could not create compact unwind for\[^\n\]*" $text "" text |
| 98 |
|
| 99 |
# Ignore dsymutil warning (tool bug is actually linker) |
| 100 |
regsub -all "(^|\n)\[^\n\]*could not find object file symbol for symbol\[^\n\]*" $text "" text |
| 101 |
|
| 102 |
# Ignore stabs obsoletion warnings |
| 103 |
regsub -all "(^|\n)\[^\n\]*\[Ww\]arning: STABS debugging information is obsolete and not supported anymore\[^\n\]*" $text "" text |
| 104 |
|
| 105 |
# Ignore missing lto jobserver for tests that do more than 1 LTRANS unit |
| 106 |
regsub -all "(^|\n)\[^\n\]*lto\[^\n\]*: warning: using serial compilation of \[^\n\]*" $text "" text |
| 107 |
regsub -all "(^|\n)\[^\n\]*lto\[^\n\]*: note: see the \[^\n\]*'-flto' option documentation\[^\n\]* for more information" $text "" text |
| 108 |
|
| 109 |
# Many tests that use visibility will still pass on platforms that don't support it. |
| 110 |
regsub -all "(^|\n)\[^\n\]*lto1: warning: visibility attribute not supported in this configuration; ignored\[^\n\]*" $text "" text |
| 111 |
|
| 112 |
#send_user "After:$text\n" |
| 113 |
|
| 114 |
return $text |
| 115 |
} |
| 116 |
|
| 117 |
# escape metacharacters in literal string, so it can be used in regex |
| 118 |
|
| 119 |
proc escape_regex_chars { line } { |
| 120 |
return [string map {"^" "\\^" |
| 121 |
"$" "\\$" |
| 122 |
"(" "\\(" |
| 123 |
")" "\\)" |
| 124 |
"[" "\\[" |
| 125 |
"]" "\\]" |
| 126 |
"{" "\\{" |
| 127 |
"}" "\\}" |
| 128 |
"." "\\." |
| 129 |
"\\" "\\\\" |
| 130 |
"?" "\\?" |
| 131 |
"+" "\\+" |
| 132 |
"*" "\\*" |
| 133 |
"|" "\\|"} $line] |
| 134 |
} |
| 135 |
|
| 136 |
proc prune_file_path { text } { |
| 137 |
global srcdir |
| 138 |
|
| 139 |
set safedir [escape_regex_chars $srcdir] |
| 140 |
regsub -all "$safedir\/" $text "" text |
| 141 |
|
| 142 |
# Truncate absolute file path into relative path. |
| 143 |
set topdir "[file dirname [file dirname [file dirname $safedir]]]" |
| 144 |
regsub -all "$topdir\/" $text "" text |
| 145 |
|
| 146 |
return $text |
| 147 |
} |
| 148 |
|
| 149 |
# Prune internal compiler error messages, including the "Please submit..." |
| 150 |
# footnote. |
| 151 |
|
| 152 |
proc prune_ices { text } { |
| 153 |
regsub -all "(^|\n)\[^\n\]*: internal compiler error:.*\nSee \[^\n\]*" $text "" text |
| 154 |
regsub -all "(^|\n|')*Internal compiler error:.*\nSee \[^\n\]*" $text "" text |
| 155 |
regsub -all "(^|\n)\[^\n\]*: internal compiler error:.*\nYou have broken GCC Rust. This is a feature." $text "" text |
| 156 |
return $text |
| 157 |
} |
| 158 |
|
| 159 |
# Provide a definition of this if missing (delete after next dejagnu release). |
| 160 |
|
| 161 |
if { [info procs prune_warnings] == "" } then { |
| 162 |
proc prune_warnings { text } { |
| 163 |
return $text |
| 164 |
} |
| 165 |
} |