lex.c (real_yylex): Treat `$' just like `_'...
authorPaul Eggert <eggert@twinsun.com>
Tue, 30 Sep 1997 05:32:19 +0000 (05:32 +0000)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 30 Sep 1997 05:32:19 +0000 (01:32 -0400)
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

gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/cp/lang-specs.h
gcc/cp/lex.c

index 27de63673793fced17b2020b98811d49b16b56f2..daa044b043b8d70cd915ad8ec21e5e6fe26192ca 100644 (file)
@@ -1,3 +1,14 @@
+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
index 50317675642b1c2395b6be7c45719e055de2293e..b99a1fa08b92c772e4fbbbee81eb0d71fad915f3 100644 (file)
@@ -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
index 11f0db28cb8e78a0c0fadee465858bff6c81cc92..381bec56ecb13c5ee6d7a3d20dd64867818d5024 100644 (file)
@@ -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\
index b60c09954eb159db07007268fd9437da10acb7e6..6abf0d09fbfe72bd0390fe8d5998dabdaf0e0679 100644 (file)
@@ -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);