c-common.c, c-common.h (dollars_in_ident): Remove.

* c-common.c, c-common.h (dollars_in_ident): Remove.
	* c-opts.c (DOLLARS_IN_IDENTIFIERS): Default to true.
	(c_common_init_options, c_common_decode_option): Set dollars_in_ident.
	* cpphash.h (warned_dollar): Rename warn_dollars.
	* cppinit.c (struct lang_flags, lang_defaults, cpp_set_lang)
	Permit dollars regardless of -std=.
	(post_options): Set warn_dollars.
	* cpplex.c (forms_identifier_p): Use warn_dollars.
	* config/darwin.h, config/alpha/vms.h, config/m68hc11/m68hc11.h:
	Remove redundant definitions of DOLLARS_IN_IDENTIFIERS.
	* doc/cpp.texi, doc/cppopts.texi, doc/invoke.texi, doc/tm.texi:
	Update documentation.
testsuite:
	* gcc.dg/dollar.c: New test.

From-SVN: r66911
This commit is contained in:
Neil Booth 2003-05-17 20:29:34 +00:00 committed by Neil Booth
parent a69e127ba7
commit b1822ccc44
16 changed files with 87 additions and 53 deletions

View File

@ -1,3 +1,18 @@
2003-05-17 Neil Booth <neil@daikokuya.co.uk>
* c-common.c, c-common.h (dollars_in_ident): Remove.
* c-opts.c (DOLLARS_IN_IDENTIFIERS): Default to true.
(c_common_init_options, c_common_decode_option): Set dollars_in_ident.
* cpphash.h (warned_dollar): Rename warn_dollars.
* cppinit.c (struct lang_flags, lang_defaults, cpp_set_lang)
Permit dollars regardless of -std=.
(post_options): Set warn_dollars.
* cpplex.c (forms_identifier_p): Use warn_dollars.
* config/darwin.h, config/alpha/vms.h, config/m68hc11/m68hc11.h:
Remove redundant definitions of DOLLARS_IN_IDENTIFIERS.
* doc/cpp.texi, doc/cppopts.texi, doc/invoke.texi, doc/tm.texi:
Update documentation.
2003-05-17 Andreas Schwab <schwab@suse.de>
* config/m68k/m68k.c (m68k_output_function_prologue): Use

View File

@ -264,13 +264,6 @@ int flag_no_asm;
int flag_const_strings;
/* Nonzero means `$' can be in an identifier. */
#ifndef DOLLARS_IN_IDENTIFIERS
#define DOLLARS_IN_IDENTIFIERS 1
#endif
int dollars_in_ident = DOLLARS_IN_IDENTIFIERS;
/* Nonzero means to treat bitfields as signed unless they say `unsigned'. */
int flag_signed_bitfields = 1;

View File

@ -434,10 +434,6 @@ extern int flag_no_asm;
extern int flag_const_strings;
/* Nonzero means `$' can be in an identifier. */
extern int dollars_in_ident;
/* Nonzero means to treat bitfields as signed unless they say `unsigned'. */
extern int flag_signed_bitfields;

View File

@ -36,6 +36,10 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "c-incpath.h"
#include "debug.h" /* For debug_hooks. */
#ifndef DOLLARS_IN_IDENTIFIERS
# define DOLLARS_IN_IDENTIFIERS true
#endif
#ifndef TARGET_SYSTEM_ROOT
# define TARGET_SYSTEM_ROOT NULL
#endif
@ -590,6 +594,7 @@ c_common_init_options (lang)
parse_in = cpp_create_reader (lang == clk_c ? CLK_GNUC89 : CLK_GNUCXX,
ident_hash);
cpp_opts = cpp_get_options (parse_in);
cpp_opts->dollars_in_ident = DOLLARS_IN_IDENTIFIERS;
if (flag_objc)
cpp_opts->objc = 1;
@ -1157,7 +1162,7 @@ c_common_decode_option (argc, argv)
break;
case OPT_fdollars_in_identifiers:
dollars_in_ident = on;
cpp_opts->dollars_in_ident = on;
break;
case OPT_fdump:

View File

@ -41,9 +41,6 @@ Boston, MA 02111-1307, USA. */
builtin_define ("__IEEE_FLOAT"); \
} while (0)
/* By default, allow $ to be part of an identifier. */
#define DOLLARS_IN_IDENTIFIERS 2
#undef TARGET_DEFAULT
#define TARGET_DEFAULT (MASK_FP|MASK_FPREGS|MASK_GAS)
#undef TARGET_ABI_OPEN_VMS

View File

@ -287,9 +287,6 @@ Boston, MA 02111-1307, USA. */
to put anything in ENDFILE_SPEC. */
/* #define ENDFILE_SPEC "" */
#undef DOLLARS_IN_IDENTIFIERS
#define DOLLARS_IN_IDENTIFIERS 2
/* We use Dbx symbol format. */
#define DBX_DEBUGGING_INFO 1

View File

@ -1706,9 +1706,6 @@ do { \
purposes) so give the MEM rtx a byte's mode. */
#define FUNCTION_MODE QImode
/* Allow $ in identifiers */
#define DOLLARS_IN_IDENTIFIERS 1
extern int debug_m6811;
extern int z_replacement_completed;
extern int current_function_interrupt;

View File

@ -378,9 +378,9 @@ struct cpp_reader
cpp_token avoid_paste;
cpp_token eof;
/* True if we have already warned about dollars in identifiers or
numbers for this buffer. */
bool warned_dollar;
/* True if we should warn about dollars in identifiers or numbers
for this translation unit. */
bool warn_dollars;
/* Opaque handle to the dependencies of mkdeps.c. */
struct deps *deps;

View File

@ -73,22 +73,20 @@ struct lang_flags
char cplusplus;
char extended_numbers;
char std;
char dollars_in_ident;
char cplusplus_comments;
char digraphs;
};
/* ??? Enable $ in identifiers in assembly? */
static const struct lang_flags lang_defaults[] =
{ /* c99 c++ xnum std dollar c++comm digr */
/* GNUC89 */ { 0, 0, 1, 0, 1, 1, 1 },
/* GNUC99 */ { 1, 0, 1, 0, 1, 1, 1 },
/* STDC89 */ { 0, 0, 0, 1, 0, 0, 0 },
/* STDC94 */ { 0, 0, 0, 1, 0, 0, 1 },
/* STDC99 */ { 1, 0, 1, 1, 0, 1, 1 },
/* GNUCXX */ { 0, 1, 1, 0, 1, 1, 1 },
/* CXX98 */ { 0, 1, 1, 1, 0, 1, 1 },
/* ASM */ { 0, 0, 1, 0, 0, 1, 0 }
{ /* c99 c++ xnum std // digr */
/* GNUC89 */ { 0, 0, 1, 0, 1, 1 },
/* GNUC99 */ { 1, 0, 1, 0, 1, 1 },
/* STDC89 */ { 0, 0, 0, 1, 0, 0 },
/* STDC94 */ { 0, 0, 0, 1, 0, 1 },
/* STDC99 */ { 1, 0, 1, 1, 1, 1 },
/* GNUCXX */ { 0, 1, 1, 0, 1, 1 },
/* CXX98 */ { 0, 1, 1, 1, 1, 1 },
/* ASM */ { 0, 0, 1, 0, 1, 0 }
};
/* Sets internal flags correctly for a given language. */
@ -106,7 +104,6 @@ cpp_set_lang (pfile, lang)
CPP_OPTION (pfile, extended_numbers) = l->extended_numbers;
CPP_OPTION (pfile, std) = l->std;
CPP_OPTION (pfile, trigraphs) = l->std;
CPP_OPTION (pfile, dollars_in_ident) = l->dollars_in_ident;
CPP_OPTION (pfile, cplusplus_comments) = l->cplusplus_comments;
CPP_OPTION (pfile, digraphs) = l->digraphs;
}
@ -153,6 +150,7 @@ cpp_create_reader (lang, table)
CPP_OPTION (pfile, warn_endif_labels) = 1;
CPP_OPTION (pfile, warn_deprecated) = 1;
CPP_OPTION (pfile, warn_long_long) = !CPP_OPTION (pfile, c99);
CPP_OPTION (pfile, dollars_in_ident) = 1;
/* Default CPP arithmetic to something sensible for the host for the
benefit of dumb users like fix-header. */
@ -572,4 +570,11 @@ post_options (pfile)
CPP_OPTION (pfile, trigraphs) = 0;
CPP_OPTION (pfile, warn_trigraphs) = 0;
}
/* C99 permits implementation-defined characters in identifiers.
The documented meaning of -std= is to turn off extensions that
conflict with the specified standard, and since a strictly
conforming program cannot contain a '$', we do not condition
their acceptance on the -std= setting. */
pfile->warn_dollars = CPP_PEDANTIC (pfile) && !CPP_OPTION (pfile, c99);
}

View File

@ -402,11 +402,9 @@ forms_identifier_p (pfile, first)
return false;
buffer->cur++;
if (CPP_PEDANTIC (pfile)
&& !pfile->state.skipping
&& !pfile->warned_dollar)
if (pfile->warn_dollars && !pfile->state.skipping)
{
pfile->warned_dollar = true;
pfile->warn_dollars = false;
cpp_error (pfile, DL_PEDWARN, "'$' in identifier or number");
}

View File

@ -3706,6 +3706,24 @@ execution character set.
Currently, GNU cpp only supports character sets that are strict supersets
of ASCII, and performs no translation of characters.
@item Identifier characters.
@anchor{Identifier characters}
The C and C++ standards allow identifiers to be composed of @samp{_}
and the alphanumeric characters. C++ and C99 also allow universal
character names (not implemented in GCC), and C99 further permits
implementation-defined characters.
GCC allows the @samp{$} character in identifiers as an extension for
most targets. This is true regardless of the @option{std=} switch,
since this extension cannot conflict with standards-conforming
programs. Currently the targets that by default do not permit
@samp{$} are AVR, IP2K, MMIX, MIPS Irix 3, ARM aout, and PowerPC
targets for the AIX and BeOS operating systems.
You can override the default with @option{-fdollars-in-identifiers} or
@option{fno-dollars-in-identifiers}. @xref{fdollars-in-identifiers}.
@item Non-empty sequences of whitespace characters.
In textual output, each whitespace sequence is collapsed to a single

View File

@ -468,6 +468,14 @@ is applied to the standard system directories.
@xref{System Headers}.
@end ifset
@item -fdollars-in-identifiers
@opindex fdollars-in-identifiers
@anchor{fdollars-in-identifiers}
Accept @samp{$} in identifiers.
@ifset cppmanual
@xref{Identifier characters}.
@end ifset
@item -fpreprocessed
@opindex fpreprocessed
Indicate to the preprocessor that the input file has already been

View File

@ -172,7 +172,7 @@ in the following sections.
@item C++ Language Options
@xref{C++ Dialect Options,,Options Controlling C++ Dialect}.
@gccoptlist{-fabi-version=@var{n} -fno-access-control -fcheck-new @gol
-fconserve-space -fno-const-strings -fdollars-in-identifiers @gol
-fconserve-space -fno-const-strings @gol
-fno-elide-constructors @gol
-fno-enforce-eh-specs -fexternal-templates @gol
-falt-external-templates @gol
@ -1313,14 +1313,6 @@ This option might be removed in a future release of G++. For maximum
portability, you should structure your code so that it works with
string constants that have type @code{const char *}.
@item -fdollars-in-identifiers
@opindex fdollars-in-identifiers
Accept @samp{$} in identifiers. You can also explicitly prohibit use of
@samp{$} with the option @option{-fno-dollars-in-identifiers}. (GNU C allows
@samp{$} by default on most target systems, but there are a few exceptions.)
Traditional C allowed the character @samp{$} to form part of
identifiers. However, ISO C and C++ forbid @samp{$} in identifiers.
@item -fno-elide-constructors
@opindex fno-elide-constructors
The C++ standard allows an implementation to omit creating a temporary

View File

@ -9064,10 +9064,10 @@ value.
@findex DOLLARS_IN_IDENTIFIERS
@item DOLLARS_IN_IDENTIFIERS
Define this macro to control use of the character @samp{$} in identifier
names. 0 means @samp{$} is not allowed by default; 1 means it is allowed.
1 is the default; there is no need to define this macro in that case.
This macro controls the compiler proper; it does not affect the preprocessor.
Define this macro to control use of the character @samp{$} in
identifier names for the C family of languages. 0 means @samp{$} is
not allowed by default; 1 means it is allowed. 1 is the default;
there is no need to define this macro in that case.
@findex NO_DOLLAR_IN_LABEL
@item NO_DOLLAR_IN_LABEL

View File

@ -1,3 +1,7 @@
2003-05-17 Neil Booth <neil@daikokuya.co.uk>
* gcc.dg/dollar.c: New test.
2003-05-16 Janis Johnson <janis187@us.ibm.com>
* gcc.dg/compat/struct-by-value-4_main.c: Split into multiple tests.

View File

@ -0,0 +1,9 @@
/* Copyright (C) 2003 Free Software Foundation, Inc. */
/* { dg-do compile } */
/* { dg-options -fno-dollars-in-identifiers } */
/* Test that -fno-dollars-in-identifiers is honoured.
Neil Booth, 17 May 2003. */
int foobar$; /* { dg-error "stray '\\$'" } */