/* C/ObjC/C++ command line option handling.
- Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007
+ Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008
Free Software Foundation, Inc.
Contributed by Neil Booth.
#include "diagnostic.h"
#include "intl.h"
#include "cppdefault.h"
-#include "c-incpath.h"
+#include "incpath.h"
#include "debug.h" /* For debug_hooks. */
#include "opts.h"
#include "options.h"
#endif
/* CPP's options. */
-static cpp_options *cpp_opts;
+cpp_options *cpp_opts;
/* Input filename. */
static const char *this_input_filename;
/* If -v seen. */
static bool verbose;
-/* If -lang-fortran seen. */
-bool lang_fortran = false;
-
/* Dependency output file. */
static const char *deps_file;
result |= CL_C | CL_ObjC | CL_CXX | CL_ObjCXX;
break;
}
-
-#ifdef CL_Fortran
- for (i = 1; i < argc; i++)
- if (! strcmp (argv[i], "-lang-fortran"))
- {
- result |= CL_Fortran;
- break;
- }
-#endif
}
return result;
result = 0;
break;
}
-#ifdef CL_Fortran
- if (lang_fortran && (cl_options[code].flags & (CL_Fortran)))
- break;
-#endif
result = 0;
break;
error ("-I- specified twice");
quote_chain_split = true;
split_quote_chain ();
- inform ("obsolete option -I- used, please use -iquote instead");
+ inform (input_location, "obsolete option -I- used, please use -iquote instead");
}
break;
break;
case OPT_Wall:
- set_Wunused (value);
+ warn_unused = value;
set_Wformat (value);
set_Wimplicit (value);
warn_char_subscripts = value;
warn_uninitialized = (value ? 2 : 0);
if (!c_dialect_cxx ())
- /* We set this to 2 here, but 1 in -Wmain, so -ffreestanding
- can turn it off only if it's not explicit. */
- warn_main = value * 2;
+ {
+ /* We set this to 2 here, but 1 in -Wmain, so -ffreestanding
+ can turn it off only if it's not explicit. */
+ if (warn_main == -1)
+ warn_main = (value ? 2 : 0);
+ }
else
{
/* C++-specific warnings. */
warn_pointer_sign = 1;
break;
+ case OPT_Wbuiltin_macro_redefined:
+ cpp_opts->warn_builtin_macro_redefined = value;
+ break;
+
case OPT_Wcomment:
case OPT_Wcomments:
cpp_opts->warn_comments = value;
cpp_opts->warn_invalid_pch = value;
break;
- case OPT_Wmain:
- if (value)
- warn_main = 1;
- else
- warn_main = -1;
- break;
-
case OPT_Wmissing_include_dirs:
cpp_opts->warn_missing_include_dirs = value;
break;
case OPT_fhosted:
flag_hosted = value;
flag_no_builtin = !value;
- /* warn_main will be 2 if set by -Wall, 1 if set by -Wmain */
- if (!value && warn_main == 2)
- warn_main = 0;
break;
case OPT_fshort_double:
cpp_opts->dollars_in_ident = false;
break;
- case OPT_lang_fortran:
- lang_fortran = true;
- break;
-
case OPT_lang_objc:
cpp_opts->objc = 1;
break;
warn_pointer_sign = 1;
if (warn_overlength_strings == -1)
warn_overlength_strings = 1;
+ if (warn_main == -1)
+ warn_main = 2;
break;
case OPT_print_objc_runtime_info:
C_COMMON_OVERRIDE_OPTIONS;
#endif
- flag_inline_trees = 1;
-
- /* Use tree inlining. */
- if (!flag_no_inline)
- flag_no_inline = 1;
- if (flag_inline_functions)
- flag_inline_trees = 2;
-
/* By default we use C99 inline semantics in GNU99 or C99 mode. C99
inline semantics are not supported in GNU89 or C89 mode. */
if (flag_gnu89_inline == -1)
else if (!flag_gnu89_inline && !flag_isoc99)
error ("-fno-gnu89-inline is only supported in GNU99 or C99 mode");
- /* If we are given more than one input file, we must use
- unit-at-a-time mode. */
- if (num_in_fnames > 1)
- flag_unit_at_a_time = 1;
-
/* Default to ObjC sjlj exception handling if NeXT runtime. */
if (flag_objc_sjlj_exceptions < 0)
flag_objc_sjlj_exceptions = flag_next_runtime;
if (warn_overlength_strings == -1 || c_dialect_cxx ())
warn_overlength_strings = 0;
- /* Adjust various flags for C++ based on command-line settings. */
- if (c_dialect_cxx ())
- {
- if (!flag_permissive)
- {
- flag_pedantic_errors = 1;
- /* FIXME: For consistency pedantic_errors should have the
- same value in the front-end and in CPP. However, this
- will break existing applications. The right fix is
- disentagle flag_permissive from flag_pedantic_errors,
- create a new diagnostic function permerror that is
- controlled by flag_permissive and convert most C++
- pedwarns to this new function.
- cpp_opts->pedantic_errors = 1; */
- }
- if (!flag_no_inline)
- {
- flag_inline_trees = 1;
- flag_no_inline = 1;
- }
- if (flag_inline_functions)
- flag_inline_trees = 2;
- }
+ /* Wmain is enabled by default in C++ but not in C. */
+ /* Wmain is disabled by default for -ffreestanding (!flag_hosted),
+ even if -Wall was given (warn_main will be 2 if set by -Wall, 1
+ if set by -Wmain). */
+ if (warn_main == -1)
+ warn_main = (c_dialect_cxx () && flag_hosted) ? 1 : 0;
+ else if (warn_main == 2)
+ warn_main = flag_hosted ? 1 : 0;
/* In C, -Wconversion enables -Wsign-conversion (unless disabled
through -Wno-sign-conversion). While in C++,
if (version_flag)
c_common_print_pch_checksum (stderr);
+ /* Has to wait until now so that cpplib has its hash table. */
+ init_pragma ();
+
if (flag_preprocess_only)
{
finish_options ();
return false;
}
- /* Has to wait until now so that cpplib has its hash table. */
- init_pragma ();
-
return true;
}
flag_dump_includes = 0;
flag_no_line_commands = 1;
}
+ else if (cpp_opts->deps.missing_files)
+ error ("-MG may only be used with -M or -MM");
cpp_opts->unsigned_char = !flag_signed_char;
cpp_opts->stdc_0_in_system_headers = STDC_0_IN_SYSTEM_HEADERS;
case 'M': /* Dump macros only. */
case 'N': /* Dump names. */
case 'D': /* Dump definitions. */
+ case 'U': /* Dump used macros. */
flag_dump_macros = c;
break;