diff options
Diffstat (limited to 'gnu')
-rw-r--r-- | gnu/egcs/gcc/cccp.c | 9 | ||||
-rw-r--r-- | gnu/egcs/gcc/cpphash.c | 41 | ||||
-rw-r--r-- | gnu/egcs/gcc/cppinit.c | 8 | ||||
-rw-r--r-- | gnu/egcs/gcc/cpplib.h | 4 | ||||
-rw-r--r-- | gnu/egcs/gcc/gcc.c | 15 |
5 files changed, 57 insertions, 20 deletions
diff --git a/gnu/egcs/gcc/cccp.c b/gnu/egcs/gcc/cccp.c index 65070224f45..dfb2157e65c 100644 --- a/gnu/egcs/gcc/cccp.c +++ b/gnu/egcs/gcc/cccp.c @@ -141,6 +141,10 @@ static int for_lint = 0; static int put_out_comments = 0; +/* Nonzero means pass comments inside macros */ + +static int pass_through_comments = 0; + /* Nonzero means don't process the ANSI trigraph sequences. */ static int no_trigraphs = 0; @@ -1677,6 +1681,8 @@ main (argc, argv) case 'C': put_out_comments = 1; + if (argv[i][2] == 'C') + pass_through_comments = 1; break; case 'E': /* -E comes from cc -E; ignore it. */ @@ -3777,7 +3783,8 @@ handle_directive (ip, op) limit = ip->buf + ip->length; unterminated = 0; already_output = 0; - keep_comments = traditional && kt->type == T_DEFINE; + keep_comments = (traditional || pass_through_comments) + && kt->type == T_DEFINE; /* #import is defined only in Objective C, or when on the NeXT. */ if (kt->type == T_IMPORT && !(objc || lookup ((U_CHAR *) "__NeXT__", -1, -1))) diff --git a/gnu/egcs/gcc/cpphash.c b/gnu/egcs/gcc/cpphash.c index 1d8a104460e..7d236bc2f71 100644 --- a/gnu/egcs/gcc/cpphash.c +++ b/gnu/egcs/gcc/cpphash.c @@ -430,20 +430,34 @@ collect_expansion (pfile, buf, limit, nargs, arglist) /* No comments inside strings. */ break; if (*p == '*') - { - /* If we find a comment that wasn't removed by - handle_directive, this must be -traditional. - So replace the comment with nothing at all. */ - exp_p--; - p += 1; - while (p < limit && !(p[-2] == '*' && p[-1] == '/')) - p++; + if (CPP_OPTIONS(pfile)->pass_through_comments) + { + /* If we find a comment that wasn't removed by + handle_directive, this must be -traditional. + So replace the comment with nothing at all. */ + *exp_p++ = *p++; + while (p < limit && !(p[-2] == '*' && p[-1] == '/')) + *exp_p++ = *p++; #if 0 - /* Mark this as a concatenation-point, - as if it had been ##. */ - concat = p; + /* Mark this as a concatenation-point, + as if it had been ##. */ + concat = p; #endif - } + } + else + { + /* If we find a comment that wasn't removed by + handle_directive, this must be -traditional. + So replace the comment with nothing at all. */ + exp_p--; + while (p < limit && !(p[-2] == '*' && p[-1] == '/')) + p++; +#if 0 + /* Mark this as a concatenation-point, + as if it had been ##. */ + concat = p; +#endif + } break; } } @@ -775,7 +789,9 @@ macarg (pfile, rest_args) int paren = 0; enum cpp_token token; char save_put_out_comments = CPP_OPTIONS (pfile)->put_out_comments; + char save_pass_through_comments = CPP_OPTIONS (pfile)->pass_through_comments; CPP_OPTIONS (pfile)->put_out_comments = 0; + CPP_OPTIONS (pfile)->pass_through_comments = 0; /* Try to parse as much of the argument as exists at this input stack level. */ @@ -817,6 +833,7 @@ macarg (pfile, rest_args) } done: + CPP_OPTIONS (pfile)->pass_through_comments = save_pass_through_comments; CPP_OPTIONS (pfile)->put_out_comments = save_put_out_comments; CPP_OPTIONS (pfile)->no_line_commands--; pfile->no_macro_expand--; diff --git a/gnu/egcs/gcc/cppinit.c b/gnu/egcs/gcc/cppinit.c index f9bc306bd52..9994b32a885 100644 --- a/gnu/egcs/gcc/cppinit.c +++ b/gnu/egcs/gcc/cppinit.c @@ -1,5 +1,6 @@ /* CPP Library. - Copyright (C) 1986, 87, 89, 92-98, 1999 Free Software Foundation, Inc. + Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, + 1999, 2000 Free Software Foundation, Inc. Contributed by Per Bothner, 1994-95. Based on CCCP program by Paul Rubin, June 1986 Adapted to ANSI C, Richard Stallman, Jan 1987 @@ -209,7 +210,8 @@ enum { QUOTE = 0, BRACKET, SYSTEM, AFTER }; /* If gcc is in use (stage2/stage3) we can make these tables initialized data. */ -#if defined __GNUC__ && __GNUC__ >= 2 +#if defined __GNUC__ && (__GNUC__ > 2 \ + || (__GNUC__ == 2 && __GNUC_MINOR__ > 8)) /* Table to tell if a character is legal as the second or later character of a C identifier. */ U_CHAR is_idchar[256] = @@ -1628,6 +1630,8 @@ cpp_handle_option (pfile, argc, argv) case 'C': opts->put_out_comments = 1; + if (argv[i][2] == 'C') + opts->pass_through_comments = 1; break; case 'E': /* -E comes from cc -E; ignore it. */ diff --git a/gnu/egcs/gcc/cpplib.h b/gnu/egcs/gcc/cpplib.h index aadec44eb86..5ef15ea5be3 100644 --- a/gnu/egcs/gcc/cpplib.h +++ b/gnu/egcs/gcc/cpplib.h @@ -360,6 +360,10 @@ struct cpp_options { char put_out_comments; + /* Nonzero means pass comments inside macros */ + + char pass_through_comments; + /* Nonzero means process the ANSI trigraph sequences. */ char trigraphs; diff --git a/gnu/egcs/gcc/gcc.c b/gnu/egcs/gcc/gcc.c index d62815473b9..457168ab06f 100644 --- a/gnu/egcs/gcc/gcc.c +++ b/gnu/egcs/gcc/gcc.c @@ -596,8 +596,9 @@ static struct compiler default_compilers[] = { #if USE_CPPLIB "%{E|M|MM:cpp0 -lang-c %{ansi:-std=c89} %{std*} %{nostdinc*}\ - %{C} %{v} %{A*} %{I*} %{P} %{$} %I\ + %{C} %{CC} %{v} %{A*} %{I*} %{P} %{$} %I\ %{C:%{!E:%eGNU C does not support -C without using -E}}\ + %{CC:%{!E:%eGNU C does not support -CC without using -E}}\ %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\ %{!no-gcc:-D__GNUC__=%v1 -D__GNUC_MINOR__=%v2}\ %{ansi|std=*:%{!std=gnu*:-trigraphs -D__STRICT_ANSI__}}\ @@ -632,8 +633,9 @@ static struct compiler default_compilers[] = %{!pipe:%g.s} %A\n }}}}" #else /* ! USE_CPPLIB */ "cpp0 -lang-c %{ansi:-std=c89} %{std*} %{nostdinc*}\ - %{C} %{v} %{A*} %{I*} %{P} %{$} %I\ + %{C} %{CC} %{v} %{A*} %{I*} %{P} %{$} %I\ %{C:%{!E:%eGNU C does not support -C without using -E}}\ + %{CC:%{!E:%eGNU C does not support -CC without using -E}}\ %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\ %{!no-gcc:-D__GNUC__=%v1 -D__GNUC_MINOR__=%v2}\ %{ansi|std=*:%{!std=gnu*:-trigraphs -D__STRICT_ANSI__}}\ @@ -660,8 +662,9 @@ static struct compiler default_compilers[] = }}, {"-", {"%{E:cpp0 -lang-c %{ansi:-std=c89} %{std*} %{nostdinc*}\ - %{C} %{v} %{A*} %{I*} %{P} %{$} %I\ + %{C} %{CC} %{v} %{A*} %{I*} %{P} %{$} %I\ %{C:%{!E:%eGNU C does not support -C without using -E}}\ + %{CC:%{!E:%eGNU C does not support -CC without using -E}}\ %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\ %{!no-gcc:-D__GNUC__=%v1 -D__GNUC_MINOR__=%v2}\ %{ansi|std=*:%{!std=gnu*:-trigraphs -D__STRICT_ANSI__}}\ @@ -677,8 +680,9 @@ static struct compiler default_compilers[] = {".h", {"@c-header"}}, {"@c-header", {"%{!E:%eCompilation of header file requested} \ - cpp0 %{nostdinc*} %{C} %{v} %{A*} %{I*} %{P} %{$} %I\ + cpp0 %{nostdinc*} %{C} %{CC} %{v} %{A*} %{I*} %{P} %{$} %I\ %{C:%{!E:%eGNU C does not support -C without using -E}}\ + %{CC:%{!E:%eGNU C does not support -CC without using -E}}\ %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\ %{!no-gcc:-D__GNUC__=%v1 -D__GNUC_MINOR__=%v2}\ %{std=*:%{!std=gnu*:-trigraphs -D__STRICT_ANSI__}}\ @@ -708,8 +712,9 @@ static struct compiler default_compilers[] = %i %A\n }}}}"}}, {".S", {"@assembler-with-cpp"}}, {"@assembler-with-cpp", - {"cpp0 -lang-asm %{nostdinc*} %{C} %{v} %{A*} %{I*} %{P} %{$} %I\ + {"cpp0 -lang-asm %{nostdinc*} %{C} %{CC} %{v} %{A*} %{I*} %{P} %{$} %I\ %{C:%{!E:%eGNU C does not support -C without using -E}}\ + %{CC:%{!E:%eGNU C does not support -CC without using -E}}\ %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG} %{trigraphs}\ -$ %{!undef:%p %P} -D__ASSEMBLER__ \ %c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}}\ |