PR c++/80972 - C++17 ICE with attribute packed.
[official-gcc.git] / gcc / opt-gather.awk
blob4d48159b296a3eb781e8d9b7a0bd9ec67f7f02b7
1 # Copyright (C) 2003-2017 Free Software Foundation, Inc.
2 # Contributed by Kelley Cook, June 2004.
3 # Original code from Neil Booth, May 2003.
5 # This program is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; either version 3, or (at your option) any
8 # later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; see the file COPYING3. If not see
17 # <http://www.gnu.org/licenses/>.
19 # This Awk script takes a list of *.opt files and combines them into
20 # a three-field sorted list suitable for input into opt[ch]-gen.awk.
22 # Usage: awk -f opt-gather.awk file1.opt [...] > outputfile
24 function sort(ARRAY, ELEMENTS)
26 for (i = 2; i <= ELEMENTS; ++i) {
27 for (j = i; ARRAY[j-1] > ARRAY[j]; --j) {
28 temp = ARRAY[j]
29 ARRAY[j] = ARRAY[j-1]
30 ARRAY[j-1] = temp
33 return
36 BEGIN { numrec = 0 }
38 # Ignore comments and blank lines
39 /^[ \t]*(;|$)/ { flag = 0; next }
40 /^[^ \t]/ { if (flag == 0) {
41 record[++numrec] = $0
42 flag = 1 }
43 else {
44 record[numrec] = record[numrec] SUBSEP $0
48 # Sort it and output it
49 END {
50 sort(record,numrec)
52 for (i = 1; i <= numrec; i++) {
53 print record[i] }