aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNeil Booth <neil@daikokuya.co.uk>2002-08-26 17:44:08 +0000
committerNeil Booth <neil@gcc.gnu.org>2002-08-26 17:44:08 +0000
commit3f66218653d7905c186e050208545d9f8d0b020f (patch)
treedc0b25913707000e58e9b178728a7b7471d099a9 /gcc
parent00e3dddac064451e35ab15d75e2f05044e56fa6b (diff)
downloadgcc-3f66218653d7905c186e050208545d9f8d0b020f.zip
gcc-3f66218653d7905c186e050208545d9f8d0b020f.tar.gz
gcc-3f66218653d7905c186e050208545d9f8d0b020f.tar.bz2
c-opts.c (find_opt): Don't complain about wrong languages here.
* c-opts.c (find_opt): Don't complain about wrong languages here. Return exact matches even for wrong language. (c_common_decode_option): Complain about wrong languages here. From-SVN: r56583
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/c-opts.c43
2 files changed, 31 insertions, 19 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 328a765..552e434 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2002-08-26 Neil Booth <neil@daikokuya.co.uk>
+
+ * c-opts.c (find_opt): Don't complain about wrong languages
+ here. Return exact matches even for wrong language.
+ (c_common_decode_option): Complain about wrong languages
+ here.
+
2002-08-24 Stuart Hastings <stuart@apple.com>
* function.h (struct function): Add flag
diff --git a/gcc/c-opts.c b/gcc/c-opts.c
index 36f11f0..1cc2048 100644
--- a/gcc/c-opts.c
+++ b/gcc/c-opts.c
@@ -374,7 +374,10 @@ missing_arg (opt_index)
Complications arise since some options can be suffixed with an
argument, and multiple complete matches can occur, e.g. -pedantic
and -pedantic-errors. Also, some options are only accepted by some
- languages. */
+ languages. If a switch matches for a different language and
+ doesn't match any alternatives for the true front end, the index of
+ the matched switch is returned anyway. The caller should check for
+ this case. */
static size_t
find_opt (input, lang_flag)
const char *input;
@@ -382,7 +385,7 @@ find_opt (input, lang_flag)
{
size_t md, mn, mx;
size_t opt_len;
- size_t wrong_lang = N_OPTS;
+ size_t result = N_OPTS;
int comp;
mn = 0;
@@ -403,13 +406,7 @@ find_opt (input, lang_flag)
{
/* The switch matches. It it an exact match? */
if (input[opt_len] == '\0')
- {
- exact_match:
- if (cl_options[md].flags & lang_flag)
- return md;
- wrong_lang = md;
- break;
- }
+ return md;
else
{
mn = md + 1;
@@ -423,9 +420,10 @@ find_opt (input, lang_flag)
/* Is this switch valid for this front end? */
if (!(cl_options[md].flags & lang_flag))
{
- /* If subsequently we don't find a good match,
- report this as a bad match. */
- wrong_lang = md;
+ /* If subsequently we don't find a better match,
+ return this and let the caller report it as a bad
+ match. */
+ result = md;
continue;
}
@@ -444,7 +442,7 @@ find_opt (input, lang_flag)
if (memcmp (input, cl_options[md].opt_text, opt_len))
break;
if (input[opt_len] == '\0')
- goto exact_match;
+ return md;
if (cl_options[md].flags & lang_flag
&& cl_options[md].flags & CL_JOINED)
mx = md;
@@ -455,10 +453,7 @@ find_opt (input, lang_flag)
}
}
- if (wrong_lang != N_OPTS)
- complain_wrong_lang (wrong_lang);
-
- return N_OPTS;
+ return result;
}
/* Defer option CODE with argument ARG. */
@@ -534,7 +529,7 @@ c_common_decode_option (argc, argv)
const char *opt, *arg = 0;
char *dup = 0;
bool on = true;
- int result;
+ int result, lang_flag;
const struct cl_option *option;
enum opt_code code;
@@ -574,7 +569,8 @@ c_common_decode_option (argc, argv)
result = cpp_handle_option (parse_in, argc, argv);
/* Skip over '-'. */
- opt_index = find_opt (opt + 1, lang_flags[(c_language << 1) + flag_objc]);
+ lang_flag = lang_flags[(c_language << 1) + flag_objc];
+ opt_index = find_opt (opt + 1, lang_flag);
if (opt_index == N_OPTS)
goto done;
@@ -610,6 +606,15 @@ c_common_decode_option (argc, argv)
}
}
+ /* Complain about the wrong language after we've swallowed any
+ necessary extra argument. Eventually make this a hard error
+ after the call to find_opt, and return argc. */
+ if (!(cl_options[opt_index].flags & lang_flag))
+ {
+ complain_wrong_lang (opt_index);
+ goto done;
+ }
+
switch (code = option->opt_code)
{
case N_OPTS: /* Shut GCC up. */