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)
* Makefile.in (parse.o, decl.o): Also depend on
......
......@@ -271,8 +271,7 @@ int warn_sign_promo;
int warn_old_style_cast;
/* Nonzero means `$' can be in an identifier.
See cccp.c for reasons why this breaks some obscure ANSI C programs. */
/* Nonzero means `$' can be in an identifier. */
#ifndef DOLLARS_IN_IDENTIFIERS
#define DOLLARS_IN_IDENTIFIERS 1
......@@ -476,7 +475,7 @@ lang_decode_option (p)
char *p;
{
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;
/* The +e options are for cfront compatibility. They come in as
`-+eN', to kludge around gcc.c's argument handling. */
......@@ -690,7 +689,7 @@ lang_decode_option (p)
else return 0;
}
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;
#ifdef SPEW_DEBUG
/* Undocumented, only ever used when you're invoking cc1plus by hand, since
......
......@@ -32,7 +32,7 @@ Boston, MA 02111-1307, USA. */
%{C:%{!E:%eGNU C++ does not support -C without using -E}}\
%{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\
-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}\
%c %{O*:%{!O0:-D__OPTIMIZE__}} %{trigraphs}\
%{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*} %Z\
......
......@@ -3095,13 +3095,12 @@ real_yylex ()
break;
case '$':
if (dollars_in_ident)
{
dollar_seen = 1;
goto letter;
}
value = '$';
goto done;
if (! dollars_in_ident)
error ("`$' in identifier");
else if (pedantic)
pedwarn ("`$' in identifier");
dollar_seen = 1;
goto letter;
case 'L':
/* Capital L may start a wide-string or wide-character constant. */
......@@ -3152,8 +3151,14 @@ real_yylex ()
input sources. */
while (isalnum (c) || (c == '_') || c == '$')
{
if (c == '$' && ! dollars_in_ident)
break;
if (c == '$')
{
if (! dollars_in_ident)
error ("`$' in identifier");
else if (pedantic)
pedwarn ("`$' in identifier");
}
if (p >= token_buffer + maxtoken)
p = extend_token_buffer (p);
......@@ -3176,8 +3181,14 @@ real_yylex ()
while (isalnum (c) || (c == '_') || c == '$')
{
if (c == '$' && ! dollars_in_ident)
break;
if (c == '$')
{
if (! dollars_in_ident)
error ("`$' in identifier");
else if (pedantic)
pedwarn ("`$' in identifier");
}
if (p >= token_buffer + maxtoken)
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