tccpp: cleanup options -dD -dM, remove -C

The lexer is for reading files, not for writing.

Also :
- macro_is_equal(): avoid crash if redefining __FILE__
This commit is contained in:
grischka
2016-05-05 14:12:53 +02:00
parent caebbc3ee1
commit fe845cf53d
5 changed files with 198 additions and 246 deletions

View File

@ -1132,18 +1132,14 @@ LIBTCCAPI TCCState *tcc_new(void)
tcc_define_symbol(s, "__linux", NULL);
# endif
# if defined(__FreeBSD__)
# define str(s) #s
tcc_define_symbol(s, "__FreeBSD__", str( __FreeBSD__));
# undef str
tcc_define_symbol(s, "__FreeBSD__", "__FreeBSD__");
# endif
# if defined(__FreeBSD_kernel__)
tcc_define_symbol(s, "__FreeBSD_kernel__", NULL);
# endif
#endif
# if defined(__NetBSD__)
# define str(s) #s
tcc_define_symbol(s, "__NetBSD__", str( __NetBSD__));
# undef str
tcc_define_symbol(s, "__NetBSD__", "__NetBSD__");
# endif
/* TinyCC & gcc defines */
@ -1227,8 +1223,6 @@ LIBTCCAPI void tcc_delete(TCCState *s1)
/* close a preprocessor output */
if (s1->ppfp && s1->ppfp != stdout)
fclose(s1->ppfp);
if (s1->dffp && s1->dffp != s1->ppfp)
fclose(s1->dffp);
/* free all sections */
for(i = 1; i < s1->nb_sections; i++)
@ -1614,12 +1608,7 @@ LIBTCCAPI int tcc_set_output_type(TCCState *s, int output_type)
if (!s->ppfp)
tcc_error("could not write '%s'", s->outfile);
}
s->dffp = s->ppfp;
if (s->dflag == 'M')
s->ppfp = NULL;
}
if (s->option_C && !s->ppfp)
s->option_C = 0;
if (!s->nostdinc) {
/* default include paths */
@ -1670,7 +1659,6 @@ LIBTCCAPI int tcc_set_output_type(TCCState *s, int output_type)
tcc_add_crt(s, "crti.o");
}
#endif
#ifdef CONFIG_TCC_BCHECK
if (s->do_bounds_check && (output_type == TCC_OUTPUT_EXE))
{
@ -1681,12 +1669,8 @@ LIBTCCAPI int tcc_set_output_type(TCCState *s, int output_type)
put_extern_sym(sym, NULL, 0, 0);
}
#endif
if (s->normalize_inc_dirs)
tcc_normalize_inc_dirs(s);
if (s->output_type == TCC_OUTPUT_PREPROCESS)
print_defines();
return 0;
}
@ -1963,7 +1947,6 @@ enum {
TCC_OPTION_b,
TCC_OPTION_g,
TCC_OPTION_c,
TCC_OPTION_C,
TCC_OPTION_dumpversion,
TCC_OPTION_d,
TCC_OPTION_float_abi,
@ -2021,7 +2004,6 @@ static const TCCOption tcc_options[] = {
#endif
{ "g", TCC_OPTION_g, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
{ "c", TCC_OPTION_c, 0 },
{ "C", TCC_OPTION_C, 0 },
{ "dumpversion", TCC_OPTION_dumpversion, 0},
{ "d", TCC_OPTION_d, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
#ifdef TCC_TARGET_ARM
@ -2210,17 +2192,15 @@ ST_FUNC int tcc_parse_args1(TCCState *s, int argc, char **argv)
tcc_warning("-c: some compiler action already specified (%d)", s->output_type);
s->output_type = TCC_OUTPUT_OBJ;
break;
case TCC_OPTION_C:
s->option_C = 1;
break;
case TCC_OPTION_d:
if (*optarg == 'D' || *optarg == 'M')
s->dflag = *optarg;
else {
if (s->warn_unsupported)
goto unsupported_option;
tcc_error("invalid option -- '%s'", r);
}
if (*optarg == 'D')
s->dflag = 3;
else if (*optarg == 'M')
s->dflag = 7;
else if (*optarg == 'b')
s->dflag = 8;
else
goto unsupported_option;
break;
#ifdef TCC_TARGET_ARM
case TCC_OPTION_float_abi:
@ -2310,12 +2290,11 @@ ST_FUNC int tcc_parse_args1(TCCState *s, int argc, char **argv)
do ++s->verbose; while (*optarg++ == 'v');
break;
case TCC_OPTION_f:
if (tcc_set_flag(s, optarg, 1) < 0 && s->warn_unsupported)
if (tcc_set_flag(s, optarg, 1) < 0)
goto unsupported_option;
break;
case TCC_OPTION_W:
if (tcc_set_warning(s, optarg, 1) < 0 &&
s->warn_unsupported)
if (tcc_set_warning(s, optarg, 1) < 0)
goto unsupported_option;
break;
case TCC_OPTION_w:
@ -2378,10 +2357,9 @@ ST_FUNC int tcc_parse_args1(TCCState *s, int argc, char **argv)
/* ignored */
break;
default:
if (s->warn_unsupported) {
unsupported_option:
unsupported_option:
if (s->warn_unsupported)
tcc_warning("unsupported option '%s'", r);
}
break;
}
}