This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Mainline compiler: Digraphs (part 2 of 2)
- To: gcc-patches at gcc dot gnu dot org
- Subject: Mainline compiler: Digraphs (part 2 of 2)
- From: Neil Booth <NeilB at earthling dot net>
- Date: Sun, 9 Jul 2000 20:09:12 +0900
This updates the mainline compiler to honour digraphs depending upon
the -std= setting. Along with the cpplib patch, it fixes Gnats #352.
Would someone with the relevant authority give this a quick look? OK
to commit?
Bootstrapping on i386 Linux.
Thanks,
Neil.
* c-common.h (flag_digraphs): New.
* c-decl.c (c_decode_option): Set flag_digraphs as appropriate.
* c-lex.c (yylex): Use flag_digraphs to decide whether to
honour digraphs.
Index: c-common.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/c-common.h,v
retrieving revision 1.22
diff -u -p -r1.22 c-common.h
--- c-common.h 2000/07/03 03:55:22 1.22
+++ c-common.h 2000/07/09 11:01:03
@@ -181,6 +181,10 @@ extern int flag_traditional;
extern int flag_isoc99;
+/* Nonzero means accept digraphs. */
+
+extern int flag_digraphs;
+
/* Nonzero means warn about suggesting putting in ()'s. */
extern int warn_parentheses;
Index: c-decl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/c-decl.c,v
retrieving revision 1.126
diff -u -p -r1.126 c-decl.c
--- c-decl.c 2000/07/02 05:22:58 1.126
+++ c-decl.c 2000/07/09 11:01:12
@@ -330,6 +330,10 @@ int flag_traditional;
int flag_isoc99 = 0;
+/* Nonzero means accept digraphs. */
+
+int flag_digraphs = 1;
+
/* Nonzero means that we have builtin functions, and main is an int */
int flag_hosted = 1;
@@ -491,6 +495,7 @@ c_decode_option (argc, argv)
{
flag_traditional = 1;
flag_writable_strings = 1;
+ flag_digraphs = 0;
}
else if (!strcmp (p, "-fallow-single-precision"))
flag_allow_single_precision = 1;
@@ -511,6 +516,7 @@ c_decode_option (argc, argv)
{
flag_traditional = 0;
flag_writable_strings = 0;
+ flag_digraphs = 1;
}
else if (!strncmp (p, "-std=", 5))
{
@@ -535,6 +541,7 @@ c_decode_option (argc, argv)
flag_no_asm = 1;
flag_no_nonansi_builtin = 1;
flag_isoc99 = 0;
+ flag_digraphs = 0;
}
else if (!strcmp (argstart, "iso9899:199409"))
{
@@ -551,6 +558,7 @@ c_decode_option (argc, argv)
flag_no_asm = 1;
flag_no_nonansi_builtin = 1;
flag_isoc99 = 1;
+ flag_digraphs = 1;
}
else if (!strcmp (argstart, "gnu89"))
{
@@ -559,6 +567,7 @@ c_decode_option (argc, argv)
flag_no_asm = 0;
flag_no_nonansi_builtin = 0;
flag_isoc99 = 0;
+ flag_digraphs = 0;
}
else if (!strcmp (argstart, "gnu9x") || !strcmp (argstart, "gnu99"))
{
@@ -567,6 +576,7 @@ c_decode_option (argc, argv)
flag_no_asm = 0;
flag_no_nonansi_builtin = 0;
flag_isoc99 = 1;
+ flag_digraphs = 1;
}
else
error ("unknown C standard `%s'", argstart);
Index: c-lex.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/c-lex.c,v
retrieving revision 1.86
diff -u -p -r1.86 c-lex.c
--- c-lex.c 2000/06/30 18:20:37 1.86
+++ c-lex.c 2000/07/09 11:01:14
@@ -2383,17 +2383,20 @@ yylex ()
/* digraphs */
case ':':
- if (c1 == '>')
+ if (c1 == '>' && flag_digraphs)
{ value = ']'; goto done; }
break;
case '<':
- if (c1 == '%')
- { value = '{'; indent_level++; goto done; }
- if (c1 == ':')
- { value = '['; goto done; }
+ if (flag_digraphs)
+ {
+ if (c1 == '%')
+ { value = '{'; indent_level++; goto done; }
+ if (c1 == ':')
+ { value = '['; goto done; }
+ }
break;
case '%':
- if (c1 == '>')
+ if (c1 == '>' && flag_digraphs)
{ value = '}'; indent_level--; goto done; }
break;
}