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
+Software Foundation; either version 3, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
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. */
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
#include "config.h"
#include "system.h"
#include "options.h"
#include "mkdeps.h"
#include "target.h"
+#include "tm_p.h"
#ifndef DOLLARS_IN_IDENTIFIERS
# define DOLLARS_IN_IDENTIFIERS true
}
parse_in = cpp_create_reader (c_dialect_cxx () ? CLK_GNUCXX: CLK_GNUC89,
- ident_hash, &line_table);
+ ident_hash, line_table);
cpp_opts = cpp_get_options (parse_in);
cpp_opts->dollars_in_ident = DOLLARS_IN_IDENTIFIERS;
warn_pointer_arith = c_dialect_cxx ();
warn_write_strings = c_dialect_cxx();
+ /* By default, C99-like requirements for complex multiply and divide. */
+ flag_complex_method = 2;
+
deferred_opts = XNEWVEC (struct deferred_opt, argc);
result = lang_flags[c_language];
warn_parentheses = value;
warn_return_type = value;
warn_sequence_point = value; /* Was C only. */
- if (c_dialect_cxx ())
- warn_sign_compare = value;
warn_switch = value;
- set_Wstrict_aliasing (value);
+ if (warn_strict_aliasing == -1)
+ set_Wstrict_aliasing (value);
warn_address = value;
- warn_strict_overflow = value;
+ if (warn_strict_overflow == -1)
+ warn_strict_overflow = value;
warn_array_bounds = value;
/* Only warn about unknown pragmas that are not in system
else
{
/* C++-specific warnings. */
+ warn_sign_compare = value;
warn_reorder = value;
- warn_nontemplate_friend = value;
warn_cxx0x_compat = value;
- if (value > 0)
- warn_write_strings = true;
}
cpp_opts->warn_trigraphs = value;
cpp_opts->warn_comments = value;
cpp_opts->warn_num_sign_change = value;
- cpp_opts->warn_multichar = value; /* Was C++ only. */
if (warn_pointer_sign == -1)
warn_pointer_sign = 1;
disable_builtin_function (arg);
break;
+ case OPT_fdirectives_only:
+ cpp_opts->directives_only = value;
+ break;
+
case OPT_fdollars_in_identifiers:
cpp_opts->dollars_in_ident = value;
break;
/* -Wextra implies -Wtype-limits, -Wclobbered,
-Wempty-body, -Wsign-compare,
-Wmissing-field-initializers, -Wmissing-parameter-type
- -Wold-style-declaration, and -Woverride-init,
+ -Wold-style-declaration, -Woverride-init and -Wignored-qualifiers
but not if explicitly overridden. */
if (warn_type_limits == -1)
warn_type_limits = extra_warnings;
warn_old_style_declaration = extra_warnings;
if (warn_override_init == -1)
warn_override_init = extra_warnings;
+ if (warn_ignored_qualifiers == -1)
+ warn_ignored_qualifiers = extra_warnings;
/* -Wpointer_sign is disabled by default, but it is enabled if any
of -Wall or -pedantic are given. */
if (warn_pointer_sign == -1)
warn_pointer_sign = 0;
+ if (warn_strict_aliasing == -1)
+ warn_strict_aliasing = 0;
+ if (warn_strict_overflow == -1)
+ warn_strict_overflow = 0;
+
/* -Woverlength-strings is off by default, but is enabled by -pedantic.
It is never enabled in C++, as the minimum limit is not normative
in that standard. */
if (!flag_permissive)
{
flag_pedantic_errors = 1;
- cpp_opts->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)
{
if (warn_implicit_function_declaration == -1)
warn_implicit_function_declaration = flag_isoc99;
- /* C99 requires special handling of complex multiplication and division;
- -ffast-math and -fcx-limited-range are handled in process_options. */
- if (flag_isoc99)
- flag_complex_method = 2;
-
/* If we're allowing C++0x constructs, don't warn about C++0x
compatibility problems. */
if (cxx_dialect == cxx0x)
if (++i >= num_in_fnames)
break;
cpp_undef_all (parse_in);
+ cpp_clear_file_cache (parse_in);
this_input_filename
= cpp_read_main_file (parse_in, in_fnames[i]);
/* If an input file is missing, abandon further compilation.
if (flag_dump_macros == 'M')
flag_no_output = 1;
+ /* By default, -fdirectives-only implies -dD. This allows subsequent phases
+ to perform proper macro expansion. */
+ if (cpp_opts->directives_only && !cpp_opts->preprocessed && !flag_dump_macros)
+ flag_dump_macros = 'D';
+
/* Disable -dD, -dN and -dI if normal output is suppressed. Allow
-dM since at least glibc relies on -M -dM to work. */
/* Also, flag_no_output implies flag_no_line_commands, always. */
/* We want -Wno-long-long to override -pedantic -std=non-c99
and/or -Wtraditional, whatever the ordering. */
cpp_opts->warn_long_long
- = warn_long_long && ((!flag_isoc99 && pedantic) || warn_traditional);
+ = warn_long_long && ((pedantic
+ && (c_dialect_cxx ()
+ ? cxx_dialect == cxx98
+ : !flag_isoc99))
+ || warn_traditional);
/* Similarly with -Wno-variadic-macros. No check for c99 here, since
this also turns off warnings about GCCs extension. */
actually output the current directory? */
if (flag_working_directory == -1)
flag_working_directory = (debug_info_level != DINFO_LEVEL_NONE);
+
+ if (cpp_opts->directives_only)
+ {
+ if (warn_unused_macros)
+ error ("-fdirectives-only is incompatible with -Wunused_macros");
+ if (cpp_opts->traditional)
+ error ("-fdirectives-only is incompatible with -traditional");
+ }
}
/* Add include path with a prefix at the front of its name. */
size_t i;
cb_file_change (parse_in,
- linemap_add (&line_table, LC_RENAME, 0,
+ linemap_add (line_table, LC_RENAME, 0,
_("<built-in>"), 0));
cpp_init_builtins (parse_in, flag_hosted);
cpp_opts->warn_dollars = (cpp_opts->pedantic && !cpp_opts->c99);
cb_file_change (parse_in,
- linemap_add (&line_table, LC_RENAME, 0,
+ linemap_add (line_table, LC_RENAME, 0,
_("<command-line>"), 0));
for (i = 0; i < deferred_count; i++)
}
}
}
+ else if (cpp_opts->directives_only)
+ cpp_init_special_builtins (parse_in);
include_cursor = 0;
push_command_line_include ();
/* Set this here so the client can change the option if it wishes,
and after stacking the main file so we don't trace the main file. */
- line_table.trace_includes = cpp_opts->print_include_names;
+ line_table->trace_includes = cpp_opts->print_include_names;
}
}