From 4f6140be61e7f75fdee7143d259b32ff16a70300 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 30 Sep 1997 05:32:19 +0000 Subject: [PATCH] lex.c (real_yylex): Treat `$' just like `_'... 1997-09-29 Paul Eggert * 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 --- gcc/cp/ChangeLog | 11 +++++++++++ gcc/cp/decl2.c | 7 +++---- gcc/cp/lang-specs.h | 2 +- gcc/cp/lex.c | 33 ++++++++++++++++++++++----------- 4 files changed, 37 insertions(+), 16 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 27de6367379..daa044b043b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,14 @@ +1997-09-29 Paul Eggert + + * 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 diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 50317675642..b99a1fa08b9 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -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 diff --git a/gcc/cp/lang-specs.h b/gcc/cp/lang-specs.h index 11f0db28cb8..381bec56ecb 100644 --- a/gcc/cp/lang-specs.h +++ b/gcc/cp/lang-specs.h @@ -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\ diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c index b60c09954eb..6abf0d09fbf 100644 --- a/gcc/cp/lex.c +++ b/gcc/cp/lex.c @@ -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); -- 2.30.2