Commit 40c79d58 by Zack Weinberg

cpplib.h (struct cpp_options): Change lang_asm to char.

2000-01-11 16:24 -0800  Zack Weinberg  <zack@wolery.cumb.org>

	* cpplib.h (struct cpp_options): Change lang_asm to char.
	Add lang_fortran.
	* cppinit.c (builtin_array): Take out __STDC_VERSION__, it's
	done in cpp_handle_option now.
	(initialize_builtins): Take out special case code used only by
	__STDC_VERSION__.
	(cpp_handle_option): Turn off trigraphs and trigraph warnings
	if -traditional.  Recognize -lang-fortran and set
	lang_fortran, also turn off cplusplus_comments.
	(print_help): Document -lang-fortran.
	* cpplib.c (handle_directive): Ignore `# 123 "file"' if
	lang_asm. Ignore all directives other than `# 123 "file"' if
	CPP_PREPROCESSED.
	(cpp_get_token): If -traditional, don't recognize directives
	unless the # is in column 1.
	(parse_string): If lang_fortran or lang_asm, silently
	terminate strings ('' or "") at end of line.
	Remove unnecessary braces.

From-SVN: r31342
parent 2e76d35c
2000-01-11 Alexandre Oliva <oliva@lsd.ic.unicamp.br>, Richard Henderson <rth@cygnus.com> 2000-01-11 16:24 -0800 Zack Weinberg <zack@wolery.cumb.org>
* cpplib.h (struct cpp_options): Change lang_asm to char.
Add lang_fortran.
* cppinit.c (builtin_array): Take out __STDC_VERSION__, it's
done in cpp_handle_option now.
(initialize_builtins): Take out special case code used only by
__STDC_VERSION__.
(cpp_handle_option): Turn off trigraphs and trigraph warnings
if -traditional. Recognize -lang-fortran and set
lang_fortran, also turn off cplusplus_comments.
(print_help): Document -lang-fortran.
* cpplib.c (handle_directive): Ignore `# 123 "file"' if
lang_asm. Ignore all directives other than `# 123 "file"' if
CPP_PREPROCESSED.
(cpp_get_token): If -traditional, don't recognize directives
unless the # is in column 1.
(parse_string): If lang_fortran or lang_asm, silently
terminate strings ('' or "") at end of line.
Remove unnecessary braces.
2000-01-11 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
Richard Henderson <rth@cygnus.com>
* resource.c (mark_referenced_resources): Mark a set strict_low_part * resource.c (mark_referenced_resources): Mark a set strict_low_part
as used. as used.
......
...@@ -496,8 +496,6 @@ cpp_cleanup (pfile) ...@@ -496,8 +496,6 @@ cpp_cleanup (pfile)
VALUE (if any). FLAGS tweaks the behavior a little: VALUE (if any). FLAGS tweaks the behavior a little:
DUMP write debug info for this macro DUMP write debug info for this macro
STDC define only if not -traditional STDC define only if not -traditional
C89 define only if -lang-c89
C9X define only if -lang-c9x
ULP value is the global user_label_prefix (which can't be ULP value is the global user_label_prefix (which can't be
put directly into the table). put directly into the table).
*/ */
...@@ -511,8 +509,6 @@ struct builtin ...@@ -511,8 +509,6 @@ struct builtin
}; };
#define DUMP 0x01 #define DUMP 0x01
#define STDC 0x02 #define STDC 0x02
#define C89 0x04
#define C9X 0x08
#define ULP 0x10 #define ULP 0x10
static const struct builtin builtin_array[] = static const struct builtin builtin_array[] =
...@@ -536,8 +532,6 @@ static const struct builtin builtin_array[] = ...@@ -536,8 +532,6 @@ static const struct builtin builtin_array[] =
{ "__PTRDIFF_TYPE__", PTRDIFF_TYPE, T_CONST, DUMP }, { "__PTRDIFF_TYPE__", PTRDIFF_TYPE, T_CONST, DUMP },
#endif #endif
{ "__WCHAR_TYPE__", WCHAR_TYPE, T_CONST, DUMP }, { "__WCHAR_TYPE__", WCHAR_TYPE, T_CONST, DUMP },
{ "__STDC_VERSION__", "199409L", T_CONST, DUMP|STDC|C89 },
{ "__STDC_VERSION__", "199909L", T_CONST, DUMP|STDC|C9X },
{ 0, 0, 0, 0 } { 0, 0, 0, 0 }
}; };
...@@ -555,10 +549,6 @@ initialize_builtins (pfile) ...@@ -555,10 +549,6 @@ initialize_builtins (pfile)
{ {
if ((b->flags & STDC) && CPP_TRADITIONAL (pfile)) if ((b->flags & STDC) && CPP_TRADITIONAL (pfile))
continue; continue;
if ((b->flags & C89) && CPP_OPTIONS (pfile)->c9x)
continue;
if ((b->flags & C9X) && !CPP_OPTIONS (pfile)->c9x)
continue;
val = (b->flags & ULP) ? user_label_prefix : b->value; val = (b->flags & ULP) ? user_label_prefix : b->value;
len = strlen (b->name); len = strlen (b->name);
...@@ -571,8 +561,6 @@ initialize_builtins (pfile) ...@@ -571,8 +561,6 @@ initialize_builtins (pfile)
} }
#undef DUMP #undef DUMP
#undef STDC #undef STDC
#undef C89
#undef C9X
#undef ULP #undef ULP
/* Another subroutine of cpp_start_read. This one sets up to do /* Another subroutine of cpp_start_read. This one sets up to do
...@@ -1312,6 +1300,8 @@ cpp_handle_option (pfile, argc, argv) ...@@ -1312,6 +1300,8 @@ cpp_handle_option (pfile, argc, argv)
{ {
opts->traditional = 1; opts->traditional = 1;
opts->cplusplus_comments = 0; opts->cplusplus_comments = 0;
opts->trigraphs = 0;
opts->warn_trigraphs = 0;
} }
else if (!strcmp (argv[i], "-trigraphs")) else if (!strcmp (argv[i], "-trigraphs"))
opts->trigraphs = 1; opts->trigraphs = 1;
...@@ -1339,6 +1329,8 @@ cpp_handle_option (pfile, argc, argv) ...@@ -1339,6 +1329,8 @@ cpp_handle_option (pfile, argc, argv)
opts->c9x = 0, opts->objc = 1; opts->c9x = 0, opts->objc = 1;
if (! strcmp (argv[i], "-lang-asm")) if (! strcmp (argv[i], "-lang-asm"))
opts->lang_asm = 1; opts->lang_asm = 1;
if (! strcmp (argv[i], "-lang-fortran"))
opts->lang_fortran = 1, opts->cplusplus_comments = 0;
if (! strcmp (argv[i], "-lint")) if (! strcmp (argv[i], "-lint"))
opts->for_lint = 1; opts->for_lint = 1;
if (! strcmp (argv[i], "-lang-chill")) if (! strcmp (argv[i], "-lang-chill"))
...@@ -1722,6 +1714,7 @@ Switches:\n\ ...@@ -1722,6 +1714,7 @@ Switches:\n\
-lang-objc Assume that the input sources are in ObjectiveC\n\ -lang-objc Assume that the input sources are in ObjectiveC\n\
-lang-objc++ Assume that the input sources are in ObjectiveC++\n\ -lang-objc++ Assume that the input sources are in ObjectiveC++\n\
-lang-asm Assume that the input sources are in assembler\n\ -lang-asm Assume that the input sources are in assembler\n\
-lang-fortran Assume that the input sources are in Fortran\n\
-lang-chill Assume that the input sources are in Chill\n\ -lang-chill Assume that the input sources are in Chill\n\
-std=<std name> Specify the conformance standard; one of:\n\ -std=<std name> Specify the conformance standard; one of:\n\
gnu89, gnu9x, c89, c9x, iso9899:1990,\n\ gnu89, gnu9x, c89, c9x, iso9899:1990,\n\
......
...@@ -527,11 +527,18 @@ handle_directive (pfile) ...@@ -527,11 +527,18 @@ handle_directive (pfile)
cpp_skip_hspace (pfile); cpp_skip_hspace (pfile);
c = PEEKC (); c = PEEKC ();
/* # followed by a number is equivalent to #line. Do not recognize
this form in assembly language source files. Complain about this
form if we're being pedantic, but not if this is regurgitated
input (preprocessed or fed back in by the C++ frontend). */
if (c >= '0' && c <= '9') if (c >= '0' && c <= '9')
{ {
/* Handle # followed by a line number. Complain about using that if (CPP_OPTIONS (pfile)->lang_asm)
form if we're being pedantic, but not if this is regurgitated {
input (preprocessed or fed back in by the C++ frontend). */ skip_rest_of_line (pfile);
return 1;
}
if (CPP_PEDANTIC (pfile) if (CPP_PEDANTIC (pfile)
&& ! CPP_PREPROCESSED (pfile) && ! CPP_PREPROCESSED (pfile)
&& ! CPP_BUFFER (pfile)->manual_pop) && ! CPP_BUFFER (pfile)->manual_pop)
...@@ -540,6 +547,11 @@ handle_directive (pfile) ...@@ -540,6 +547,11 @@ handle_directive (pfile)
return 1; return 1;
} }
/* If we are rescanning preprocessed input, don't obey any directives
other than # nnn. */
if (CPP_PREPROCESSED (pfile))
return 0;
/* Now find the directive name. */ /* Now find the directive name. */
CPP_PUTC (pfile, '#'); CPP_PUTC (pfile, '#');
parse_name (pfile, GETC()); parse_name (pfile, GETC());
...@@ -2388,6 +2400,12 @@ cpp_get_token (pfile) ...@@ -2388,6 +2400,12 @@ cpp_get_token (pfile)
if (!pfile->only_seen_white) if (!pfile->only_seen_white)
goto randomchar; goto randomchar;
/* -traditional directives are recognized only with the # in
column 1.
XXX Layering violation. */
if (CPP_TRADITIONAL (pfile)
&& CPP_BUFFER (pfile)->cur - CPP_BUFFER (pfile)->line_base != 1)
goto randomchar;
if (handle_directive (pfile)) if (handle_directive (pfile))
return CPP_DIRECTIVE; return CPP_DIRECTIVE;
pfile->only_seen_white = 0; pfile->only_seen_white = 0;
...@@ -2872,9 +2890,17 @@ parse_string (pfile, c) ...@@ -2872,9 +2890,17 @@ parse_string (pfile, c)
case '\n': case '\n':
CPP_BUMP_LINE (pfile); CPP_BUMP_LINE (pfile);
pfile->lineno++; pfile->lineno++;
/* In Fortran and assembly language, silently terminate
strings of either variety at end of line. This is a
kludge around not knowing where comments are in these
languages. */
if (CPP_OPTIONS (pfile)->lang_fortran
|| CPP_OPTIONS (pfile)->lang_asm)
return;
/* Character constants may not extend over multiple lines. /* Character constants may not extend over multiple lines.
In ANSI, neither may strings. We accept multiline strings In Standard C, neither may strings. We accept multiline
as an extension. */ strings as an extension. */
if (c == '\'') if (c == '\'')
{ {
cpp_error_with_line (pfile, start_line, start_column, cpp_error_with_line (pfile, start_line, start_column,
...@@ -2882,10 +2908,8 @@ parse_string (pfile, c) ...@@ -2882,10 +2908,8 @@ parse_string (pfile, c)
return; return;
} }
if (CPP_PEDANTIC (pfile) && pfile->multiline_string_line == 0) if (CPP_PEDANTIC (pfile) && pfile->multiline_string_line == 0)
{ cpp_pedwarn_with_line (pfile, start_line, start_column,
cpp_pedwarn_with_line (pfile, start_line, start_column, "string constant runs past end of line");
"string constant runs past end of line");
}
if (pfile->multiline_string_line == 0) if (pfile->multiline_string_line == 0)
pfile->multiline_string_line = start_line; pfile->multiline_string_line = start_line;
break; break;
......
...@@ -346,10 +346,18 @@ struct cpp_options { ...@@ -346,10 +346,18 @@ struct cpp_options {
char objc; char objc;
/* Nonzero means this is an assembly file, and allow /* Nonzero means this is an assembly file, so ignore unrecognized
unknown directives, which could be comments. */ directives and the "# 33" form of #line, both of which are
probably comments. Also, permit unbalanced ' strings (again,
likely to be in comments). */
int lang_asm; char lang_asm;
/* Nonzero means this is Fortran, and we don't know where the
comments are, so permit unbalanced ' strings. Unlike lang_asm,
this does not ignore unrecognized directives. */
char lang_fortran;
/* Nonzero means turn NOTREACHED into #pragma NOTREACHED etc */ /* Nonzero means turn NOTREACHED into #pragma NOTREACHED etc */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment