Commit 4f6140be by Paul Eggert Committed by Jason Merrill

lex.c (real_yylex): Treat `$' just like `_'...

1997-09-29  Paul Eggert  <eggert@twinsun.com>

	* lex.c (real_yylex): Treat `$' just like `_', except issue a
	diagnostic if !dollars_in_ident or if pedantic.

	* lang-specs.h (@c++): -ansi no longer implies -$.

	* decl2.c (lang_decode_option):
	-traditional and -ansi now do not mess with
	dollars_in_ident.

From-SVN: r15802
parent 9f617717
1997-09-29 Paul Eggert <eggert@twinsun.com>
* lex.c (real_yylex): Treat `$' just like `_', except issue a
diagnostic if !dollars_in_ident or if pedantic.
* lang-specs.h (@c++): -ansi no longer implies -$.
* decl2.c (lang_decode_option):
-traditional and -ansi now do not mess with
dollars_in_ident.
Mon Sep 29 19:57:51 1997 H.J. Lu (hjl@gnu.ai.mit.edu) Mon Sep 29 19:57:51 1997 H.J. Lu (hjl@gnu.ai.mit.edu)
* Makefile.in (parse.o, decl.o): Also depend on * Makefile.in (parse.o, decl.o): Also depend on
......
...@@ -271,8 +271,7 @@ int warn_sign_promo; ...@@ -271,8 +271,7 @@ int warn_sign_promo;
int warn_old_style_cast; int warn_old_style_cast;
/* Nonzero means `$' can be in an identifier. /* Nonzero means `$' can be in an identifier. */
See cccp.c for reasons why this breaks some obscure ANSI C programs. */
#ifndef DOLLARS_IN_IDENTIFIERS #ifndef DOLLARS_IN_IDENTIFIERS
#define DOLLARS_IN_IDENTIFIERS 1 #define DOLLARS_IN_IDENTIFIERS 1
...@@ -476,7 +475,7 @@ lang_decode_option (p) ...@@ -476,7 +475,7 @@ lang_decode_option (p)
char *p; char *p;
{ {
if (!strcmp (p, "-ftraditional") || !strcmp (p, "-traditional")) if (!strcmp (p, "-ftraditional") || !strcmp (p, "-traditional"))
dollars_in_ident = 1, flag_writable_strings = 1, flag_writable_strings = 1,
flag_this_is_variable = 1, flag_new_for_scope = 0; flag_this_is_variable = 1, flag_new_for_scope = 0;
/* The +e options are for cfront compatibility. They come in as /* The +e options are for cfront compatibility. They come in as
`-+eN', to kludge around gcc.c's argument handling. */ `-+eN', to kludge around gcc.c's argument handling. */
...@@ -690,7 +689,7 @@ lang_decode_option (p) ...@@ -690,7 +689,7 @@ lang_decode_option (p)
else return 0; else return 0;
} }
else if (!strcmp (p, "-ansi")) else if (!strcmp (p, "-ansi"))
dollars_in_ident = 0, flag_no_nonansi_builtin = 1, flag_ansi = 1, flag_no_nonansi_builtin = 1, flag_ansi = 1,
flag_no_gnu_keywords = 1, flag_operator_names = 1; flag_no_gnu_keywords = 1, flag_operator_names = 1;
#ifdef SPEW_DEBUG #ifdef SPEW_DEBUG
/* Undocumented, only ever used when you're invoking cc1plus by hand, since /* Undocumented, only ever used when you're invoking cc1plus by hand, since
......
...@@ -32,7 +32,7 @@ Boston, MA 02111-1307, USA. */ ...@@ -32,7 +32,7 @@ Boston, MA 02111-1307, USA. */
%{C:%{!E:%eGNU C++ does not support -C without using -E}}\ %{C:%{!E:%eGNU C++ does not support -C without using -E}}\
%{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\ %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\
-undef -D__GNUC__=%v1 -D__GNUG__=%v1 -D__cplusplus -D__GNUC_MINOR__=%v2\ -undef -D__GNUC__=%v1 -D__GNUG__=%v1 -D__cplusplus -D__GNUC_MINOR__=%v2\
%{ansi:-trigraphs -$ -D__STRICT_ANSI__} %{!undef:%{!ansi:%p} %P}\ %{ansi:-trigraphs -D__STRICT_ANSI__} %{!undef:%{!ansi:%p} %P}\
%{!fno-exceptions:-D__EXCEPTIONS}\ %{!fno-exceptions:-D__EXCEPTIONS}\
%c %{O*:%{!O0:-D__OPTIMIZE__}} %{trigraphs}\ %c %{O*:%{!O0:-D__OPTIMIZE__}} %{trigraphs}\
%{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*} %Z\ %{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*} %Z\
......
...@@ -3095,13 +3095,12 @@ real_yylex () ...@@ -3095,13 +3095,12 @@ real_yylex ()
break; break;
case '$': case '$':
if (dollars_in_ident) if (! dollars_in_ident)
{ error ("`$' in identifier");
dollar_seen = 1; else if (pedantic)
goto letter; pedwarn ("`$' in identifier");
} dollar_seen = 1;
value = '$'; goto letter;
goto done;
case 'L': case 'L':
/* Capital L may start a wide-string or wide-character constant. */ /* Capital L may start a wide-string or wide-character constant. */
...@@ -3152,8 +3151,14 @@ real_yylex () ...@@ -3152,8 +3151,14 @@ real_yylex ()
input sources. */ input sources. */
while (isalnum (c) || (c == '_') || c == '$') while (isalnum (c) || (c == '_') || c == '$')
{ {
if (c == '$' && ! dollars_in_ident) if (c == '$')
break; {
if (! dollars_in_ident)
error ("`$' in identifier");
else if (pedantic)
pedwarn ("`$' in identifier");
}
if (p >= token_buffer + maxtoken) if (p >= token_buffer + maxtoken)
p = extend_token_buffer (p); p = extend_token_buffer (p);
...@@ -3176,8 +3181,14 @@ real_yylex () ...@@ -3176,8 +3181,14 @@ real_yylex ()
while (isalnum (c) || (c == '_') || c == '$') while (isalnum (c) || (c == '_') || c == '$')
{ {
if (c == '$' && ! dollars_in_ident) if (c == '$')
break; {
if (! dollars_in_ident)
error ("`$' in identifier");
else if (pedantic)
pedwarn ("`$' in identifier");
}
if (p >= token_buffer + maxtoken) if (p >= token_buffer + maxtoken)
p = extend_token_buffer (p); p = extend_token_buffer (p);
......
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