* options.h (DEFINE_var): Add set_user_set_##varname__.

(DEFINE_bool_alias): New macro.
	(class General_options): Define -Bstatic using DEFINE_bool_alias
	rather than DEFINE_special.  Add --undefined as an alias for -z
	defs.
	* options.cc (General_options::parse_Bstatic): Remove.
This commit is contained in:
Ian Lance Taylor 2008-05-06 20:40:33 +00:00
parent b1e6fd1961
commit 2b706932ee
3 changed files with 66 additions and 10 deletions

View File

@ -1,5 +1,12 @@
2008-05-06 Ian Lance Taylor <iant@google.com>
* options.h (DEFINE_var): Add set_user_set_##varname__.
(DEFINE_bool_alias): New macro.
(class General_options): Define -Bstatic using DEFINE_bool_alias
rather than DEFINE_special. Add --undefined as an alias for -z
defs.
* options.cc (General_options::parse_Bstatic): Remove.
* options.h (class General_options): Add --fatal-warnings.
* main.cc (main): Implement --fatal-warnings.
* errors.h (Errors::warning_count): New function.

View File

@ -281,12 +281,6 @@ General_options::parse_V(const char*, const char*, Command_line*)
printf(" %s\n", *p);
}
void
General_options::parse_Bstatic(const char*, const char*, Command_line*)
{
this->set_Bdynamic(false);
}
void
General_options::parse_defsym(const char*, const char* arg,
Command_line* cmdline)

View File

@ -239,6 +239,10 @@ struct Struct_special : public Struct_var
user_set_##varname__() const \
{ return this->varname__##_.user_set_via_option; } \
\
void \
set_user_set_##varname__() \
{ this->varname__##_.user_set_via_option = true; } \
\
private: \
struct Struct_##varname__ : public options::Struct_var \
{ \
@ -390,6 +394,53 @@ struct Struct_special : public Struct_var
choices, sizeof(choices) / sizeof(*choices)); \
}
// This is like DEFINE_bool, but VARNAME is the name of a different
// option. This option becomes an alias for that one. INVERT is true
// if this option is an inversion of the other one.
#define DEFINE_bool_alias(option__, varname__, dashes__, shortname__, \
helpstring__, no_helpstring__, invert__) \
private: \
struct Struct_##option__ : public options::Struct_var \
{ \
Struct_##option__() \
: option(#option__, dashes__, shortname__, "", helpstring__, \
NULL, false, this) \
{ } \
\
void \
parse_to_value(const char*, const char*, \
Command_line*, General_options* options) \
{ \
options->set_##varname__(!invert__); \
options->set_user_set_##varname__(); \
} \
\
options::One_option option; \
}; \
Struct_##option__ option__##_; \
\
struct Struct_no_##option__ : public options::Struct_var \
{ \
Struct_no_##option__() \
: option((dashes__ == options::DASH_Z \
? "no" #option__ \
: "no-" #option__), \
dashes__, '\0', "", no_helpstring__, \
NULL, false, this) \
{ } \
\
void \
parse_to_value(const char*, const char*, \
Command_line*, General_options* options) \
{ \
options->set_##varname__(invert__); \
options->set_user_set_##varname__(); \
} \
\
options::One_option option; \
}; \
Struct_no_##option__ no_##option__##_initializer_
// This is used for non-standard flags. It defines no functions; it
// just calls General_options::parse_VARNAME whenever the flag is
// seen. We declare parse_VARNAME as a static member of
@ -502,10 +553,9 @@ class General_options
DEFINE_bool(Bdynamic, options::ONE_DASH, '\0', true,
N_("-l searches for shared libraries"), NULL);
// Bstatic affects the same variable as Bdynamic, so we have to use
// the "special" macro to make that happen.
DEFINE_special(Bstatic, options::ONE_DASH, '\0',
N_("-l does not search for shared libraries"), NULL);
DEFINE_bool_alias(Bstatic, Bdynamic, options::ONE_DASH, '\0',
N_("-l does not search for shared libraries"), NULL,
true);
DEFINE_bool(Bsymbolic, options::ONE_DASH, '\0', false,
N_("Bind defined symbols locally"), NULL);
@ -683,6 +733,11 @@ class General_options
DEFINE_uint64(Ttext, options::ONE_DASH, '\0', -1U,
N_("Set the address of the text segment"), N_("ADDRESS"));
DEFINE_bool_alias(undefined, defs, options::TWO_DASHES, '\0',
"Allow undefined symbols with --shared",
"Report undefined symbols (even with --shared)",
true);
DEFINE_bool(verbose, options::TWO_DASHES, '\0', false,
N_("Synonym for --debug=files"), NULL);