From c691145a655ed6fe191c2f7ce3220f19e46d2c3f Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Sat, 3 Mar 2001 11:32:32 +0000 Subject: [PATCH] cpp.texi: Update. * cpp.texi: Update. * cppexp.c (parse_number): Update. * cpplex.c (parse_string): Pedwarn if multiline string does not result from a system header's macro. * cpplib.h (sys_objmacro_p): Rename sys_macro_p. * cppmacro.c (sys_objmacro_p): Rename sys_macro_p. Return true for function-like macros too. * c-lex.c (parse_number): Update. From-SVN: r40211 --- gcc/ChangeLog | 11 +++++++++++ gcc/c-lex.c | 6 +++--- gcc/cpp.texi | 24 ++++++++++++++---------- gcc/cppexp.c | 2 +- gcc/cpplex.c | 8 +++----- gcc/cpplib.h | 2 +- gcc/cppmacro.c | 4 ++-- 7 files changed, 35 insertions(+), 22 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 23eba3be210..c818ddcc81d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2001-03-03 Neil Booth + + * cpp.texi: Update. + * cppexp.c (parse_number): Update. + * cpplex.c (parse_string): Pedwarn if multiline string does not + result from a system header's macro. + * cpplib.h (sys_objmacro_p): Rename sys_macro_p. + * cppmacro.c (sys_objmacro_p): Rename sys_macro_p. Return true + for function-like macros too. + * c-lex.c (lex_number): Update. + 2001-03-03 Richard Henderson * dwarf2out.c (output_call_frame_info): Fix augmentation length. diff --git a/gcc/c-lex.c b/gcc/c-lex.c index 9078361ad15..1af7cd645da 100644 --- a/gcc/c-lex.c +++ b/gcc/c-lex.c @@ -1227,7 +1227,7 @@ lex_number (str, len) if (fflag) ERROR ("more than one 'f' suffix on floating constant"); else if (warn_traditional && !in_system_header - && ! cpp_sys_objmacro_p (parse_in)) + && ! cpp_sys_macro_p (parse_in)) warning ("traditional C rejects the 'f' suffix"); fflag = 1; @@ -1237,7 +1237,7 @@ lex_number (str, len) if (lflag) ERROR ("more than one 'l' suffix on floating constant"); else if (warn_traditional && !in_system_header - && ! cpp_sys_objmacro_p (parse_in)) + && ! cpp_sys_macro_p (parse_in)) warning ("traditional C rejects the 'l' suffix"); lflag = 1; @@ -1313,7 +1313,7 @@ lex_number (str, len) if (spec_unsigned) error ("two 'u' suffixes on integer constant"); else if (warn_traditional && !in_system_header - && ! cpp_sys_objmacro_p (parse_in)) + && ! cpp_sys_macro_p (parse_in)) warning ("traditional C rejects the 'u' suffix"); spec_unsigned = 1; diff --git a/gcc/cpp.texi b/gcc/cpp.texi index 79efd480aff..8bfa8c40245 100644 --- a/gcc/cpp.texi +++ b/gcc/cpp.texi @@ -170,9 +170,9 @@ spaces, horizontal and vertical tabs, and form feeds between the backslash and the subsequent newline. The preprocessor issues a warning, but treats it as a valid escaped newline and combines the two lines to form a single logical line. This works within comments and -tokens, including multi-line strings, as well as between tokens. -Comments are @emph{not} treated as whitespace for the purposes of this -relaxation, since they have not yet been replaced with spaces. +tokens, as well as between tokens. Comments are @emph{not} treated as +whitespace for the purposes of this relaxation, since they have not yet +been replaced with spaces. @item All comments are replaced with single spaces. @@ -216,8 +216,9 @@ bar" @end example is equivalent to @code{"foo\bar"}, not to @code{"foo\\bar"}. To avoid -having to worry about this, do not use the GNU extension which permits -multi-line strings. Instead, use string constant concatenation: +having to worry about this, do not use the deprecated GNU extension +which permits multi-line strings. Instead, use string literal +concatenation: @example "foo\\" @@ -3053,12 +3054,15 @@ used at all. This pragma has been superseded by @samp{#pragma GCC poison}. @xref{Poisoning}. -@item Multi-line string literals in directives +@item Multi-line string literals -The GNU C preprocessor currently allows newlines in string literals -within a directive. This is forbidden by the C standard and will -eventually be removed. (Multi-line string literals in open text are -still supported.) +The preprocessor currently allows raw newlines in string literals. This +extension is deprecated and will be removed in a future version of GCC. +The preprocessor already forbids such string literals in all directives +apart from #define. + +Instead, make use of ISO C concatenation of adjacent string literals, or +use @samp{\n} followed by an escaped newline. @item Preprocessing things which are not C diff --git a/gcc/cppexp.c b/gcc/cppexp.c index 6ce693e48cc..1231a7e2669 100644 --- a/gcc/cppexp.c +++ b/gcc/cppexp.c @@ -205,7 +205,7 @@ parse_number (pfile, tok) if (CPP_WTRADITIONAL (pfile) && sufftab[i].u - && ! cpp_sys_objmacro_p (pfile)) + && ! cpp_sys_macro_p (pfile)) cpp_warning (pfile, "traditional C rejects the `U' suffix"); if (sufftab[i].l == 2 && CPP_OPTION (pfile, pedantic) && ! CPP_OPTION (pfile, c99)) diff --git a/gcc/cpplex.c b/gcc/cpplex.c index 1d98b056a63..c0b5e026ae2 100644 --- a/gcc/cpplex.c +++ b/gcc/cpplex.c @@ -686,12 +686,10 @@ parse_string (pfile, token, terminator) break; } + if (! cpp_sys_macro_p (pfile)) + cpp_pedwarn (pfile, "multi-line string constants are deprecated"); if (pfile->mlstring_pos.line == 0) - { - pfile->mlstring_pos = pfile->lexer_pos; - if (CPP_PEDANTIC (pfile)) - cpp_pedwarn (pfile, "multi-line string constant"); - } + pfile->mlstring_pos = pfile->lexer_pos; handle_newline (buffer, c); /* Stores to read_ahead. */ c = '\n'; diff --git a/gcc/cpplib.h b/gcc/cpplib.h index 50d3bfe5de8..eaa0ff9e2ba 100644 --- a/gcc/cpplib.h +++ b/gcc/cpplib.h @@ -605,7 +605,7 @@ extern void cpp_forall_identifiers PARAMS ((cpp_reader *, extern void cpp_scan_buffer_nooutput PARAMS ((cpp_reader *, int)); extern void cpp_start_lookahead PARAMS ((cpp_reader *)); extern void cpp_stop_lookahead PARAMS ((cpp_reader *, int)); -extern int cpp_sys_objmacro_p PARAMS ((cpp_reader *)); +extern int cpp_sys_macro_p PARAMS ((cpp_reader *)); /* In cppfiles.c */ extern int cpp_included PARAMS ((cpp_reader *, const char *)); diff --git a/gcc/cppmacro.c b/gcc/cppmacro.c index 4d4302dcbca..d424a4146e9 100644 --- a/gcc/cppmacro.c +++ b/gcc/cppmacro.c @@ -988,12 +988,12 @@ cpp_get_token (pfile, token) defined in a system header. Just checks the macro at the top of the stack. Used for diagnostic suppression. */ int -cpp_sys_objmacro_p (pfile) +cpp_sys_macro_p (pfile) cpp_reader *pfile; { cpp_macro *macro = pfile->context->macro; - return macro && ! macro->fun_like && macro->syshdr; + return macro && macro->syshdr; } /* Read each token in, until EOF. Directives are transparently -- 2.30.2