* Makefile.in (WERROR_FLAGS): Renamed from WERROR.
[official-gcc.git] / libstdc++-v3 / testsuite / abi_check.cc
blobe0991e7a4da3d541d6226420c2565bb80e2a5c08
1 // -*- C++ -*-
3 // Copyright (C) 2004 Free Software Foundation, Inc.
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License as
7 // published by the Free Software Foundation; either version 2, or (at
8 // your option) any later version.
10 // This library is distributed in the hope that it will be useful, but
11 // WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this library; see the file COPYING. If not, write to
17 // the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
18 // MA 02111-1307, USA.
20 // As a special exception, you may use this file as part of a free
21 // software library without restriction. Specifically, if other files
22 // instantiate templates or use macros or inline functions from this
23 // file, or you compile this file and link it with other files to
24 // produce an executable, this file does not by itself cause the
25 // resulting executable to be covered by the GNU General Public
26 // License. This exception does not however invalidate any other
27 // reasons why the executable file might be covered by the GNU General
28 // Public License.
30 // Benjamin Kosnik <bkoz@redhat.com>
31 // Blame subsequent hacks on Loren J. Rittle <ljrittle@acm.org>, Phil
32 // Edwards <pme@gcc.gnu.org>, and a cast of dozens at libstdc++@gcc.gnu.org.
34 #include "testsuite_abi.h"
35 #include <iostream>
36 #include <unistd.h> // for access(2)
38 int
39 main(int argc, char** argv)
41 using namespace std;
43 // Get arguments. (Heading towards getopt_long, I can feel it.)
44 string argv1 = argc > 1 ? argv[1] : "";
45 if (argv1 == "--help" || argc < 4)
47 cerr << "usage: abi_check --check current baseline\n"
48 " --check-verbose current baseline\n"
49 " --examine symbol current\n"
50 " --help\n"
51 "\n"
52 "All arguments are string literals.\n"
53 "CURRENT is a file generated byextract_symvers.\n"
54 "BASELINE is a file from config/abi.\n"
55 "SYMBOL is a mangled name.\n"
56 << endl;
57 exit(1);
60 if (argv1.find("--check") != string::npos)
62 bool verbose = false;
63 if (argv1 == "--check-verbose")
64 verbose = true;
66 // Quick sanity/setup check for arguments.
67 const char* test_file = argv[2];
68 const char* baseline_file = argv[3];
69 if (access(test_file, R_OK) != 0)
71 cerr << "Cannot read symbols file " << test_file
72 << ", did you forget to build first?" << endl;
73 exit(1);
75 if (access(baseline_file, R_OK) != 0)
77 cerr << "Cannot read baseline file " << baseline_file << endl;
78 exit(1);
80 compare_symbols(baseline_file, test_file, verbose);
83 if (argv1 == "--examine")
85 const char* file = argv[3];
86 if (access(file, R_OK) != 0)
88 cerr << "Cannot read symbol file " << file << endl;
89 exit(1);
91 examine_symbol(argv[2], file);
93 return 0;