/* C/ObjC/C++ command line option handling.
Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
Contributed by Neil Booth.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING. If not, write to the Free
Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA. */
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "tree.h"
#include "c-common.h"
#include "c-pragma.h"
#include "flags.h"
#include "toplev.h"
#include "langhooks.h"
#include "tree-inline.h"
#include "diagnostic.h"
#include "intl.h"
#include "cppdefault.h"
#include "c-incpath.h"
#include "debug.h" /* For debug_hooks. */
#include "opts.h"
#include "options.h"
#include "mkdeps.h"
#ifndef DOLLARS_IN_IDENTIFIERS
# define DOLLARS_IN_IDENTIFIERS true
#endif
#ifndef TARGET_SYSTEM_ROOT
# define TARGET_SYSTEM_ROOT NULL
#endif
#ifndef TARGET_OPTF
#define TARGET_OPTF(ARG)
#endif
/* CPP's options. */
static cpp_options *cpp_opts;
/* Input filename. */
static const char *this_input_filename;
/* Filename and stream for preprocessed output. */
static const char *out_fname;
static FILE *out_stream;
/* Append dependencies to deps_file. */
static bool deps_append;
/* If dependency switches (-MF etc.) have been given. */
static bool deps_seen;
/* If -v seen. */
static bool verbose;
/* If -lang-fortran seen. */
static bool lang_fortran = false;
/* Dependency output file. */
static const char *deps_file;
/* The prefix given by -iprefix, if any. */
static const char *iprefix;
/* The multilib directory given by -imultilib, if any. */
static const char *imultilib;
/* The system root, if any. Overridden by -isysroot. */
static const char *sysroot = TARGET_SYSTEM_ROOT;
/* Zero disables all standard directories for headers. */
static bool std_inc = true;
/* Zero disables the C++-specific standard directories for headers. */
static bool std_cxx_inc = true;
/* If the quote chain has been split by -I-. */
static bool quote_chain_split;
/* If -Wunused-macros. */
static bool warn_unused_macros;
/* If -Wvariadic-macros. */
static bool warn_variadic_macros = true;
/* Number of deferred options. */
static size_t deferred_count;
/* Number of deferred options scanned for -include. */
static size_t include_cursor;
static void set_Wimplicit (int);
static void handle_OPT_d (const char *);
static void set_std_cxx98 (int);
static void set_std_c89 (int, int);
static void set_std_c99 (int);
static void check_deps_environment_vars (void);
static void handle_deferred_opts (void);
static void sanitize_cpp_opts (void);
static void add_prefixed_path (const char *, size_t);
static void push_command_line_include (void);
static void cb_file_change (cpp_reader *, const struct line_map *);
static void cb_dir_change (cpp_reader *, const char *);
static void finish_options (void);
#ifndef STDC_0_IN_SYSTEM_HEADERS
#define STDC_0_IN_SYSTEM_HEADERS 0
#endif
/* Holds switches parsed by c_common_handle_option (), but whose
handling is deferred to c_common_post_options (). */
static void defer_opt (enum opt_code, const char *);
static struct deferred_opt
{
enum opt_code code;
const char *arg;
} *deferred_opts;
/* Complain that switch CODE expects an argument but none was
provided. OPT was the command-line option. Return FALSE to get
the default message in opts.c, TRUE if we provide a specialized
one. */
bool
c_common_missing_argument (const char *opt, size_t code)
{
switch (code)
{
default:
/* Pick up the default message. */
return false;
case OPT_fconstant_string_class_:
error ("no class name specified with %qs", opt);
break;
case OPT_A:
error ("assertion missing after %qs", opt);
break;
|