diff options
author | Ulrich Drepper <drepper@cygnus.com> | 1998-12-01 21:05:17 +0000 |
---|---|---|
committer | Richard Henderson <rth@gcc.gnu.org> | 1998-12-01 13:05:17 -0800 |
commit | 6f4d72224e91330c6c02d5b96b04b97e84024589 (patch) | |
tree | 8180a32dab64f00b8c46fedcdc5e7b9928102158 /gcc/cccp.c | |
parent | 8da31fc17102a9413921d73c8b15834851eba567 (diff) | |
download | gcc-6f4d72224e91330c6c02d5b96b04b97e84024589.zip gcc-6f4d72224e91330c6c02d5b96b04b97e84024589.tar.gz gcc-6f4d72224e91330c6c02d5b96b04b97e84024589.tar.bz2 |
c-common.c (declare_function_name): Declare predefinied variable `__func__'.
* c-common.c (declare_function_name): Declare predefinied variable
`__func__'.
* c-decl.c (flag_isoc9x): Set to 1 by default.
(c_decode_option): Handle -std= option. Remove -flang-isoc9x.
(grokdeclarator): Always emit warning about implicit int for ISO C 9x.
* c-parse.in: Allow constructors in ISO C 9x.
Rewrite designator list handling.
Allow [*] parameters.
Don't warn about comma at end of enum definition for ISO C 9x.
* cccp.c (c9x): New variable.
(rest_extension): New variable.
(print_help): Document new -std= option.
(main): Recognize -std= option. Set c9x appropriately.
(create_definition): Recognize ISO C 9x vararg macros.
* gcc.c (default_compilers): Adjust specs for -std options.
(option_map): Add --std.
(display_help): Document -std.
* toplev.c (documented_lang_options): Add -std and remove
-flang-isoc9x.
* c-lex.c (yylex): Recognize hex FP constants and call REAL_VALUE_ATOF
or REAL_VALUE_HTOF based on base of the constants.
* fold-const.c (real_hex_to_f): New function. Replacement function
for hex FP conversion if REAL_ARITHMETIC is not defined.
* real.c (asctoeg): Add handling of hex FP constants.
* real.h: Define REAL_VALUE_HTOF if necessary using ereal_atof or
real_hex_to_f.
Co-Authored-By: Richard Henderson <rth@cygnus.com>
Co-Authored-By: Stephen L Moshier <moshier@world.std.com>
From-SVN: r24049
Diffstat (limited to 'gcc/cccp.c')
-rw-r--r-- | gcc/cccp.c | 79 |
1 files changed, 65 insertions, 14 deletions
@@ -285,6 +285,10 @@ int traditional; int c89; +/* Nonzero for the 199x C Standard. */ + +int c9x; + /* Nonzero causes output not to be done, but directives such as #define that have side effects are still obeyed. */ @@ -604,6 +608,11 @@ union hashval { static char rest_extension[] = "..."; #define REST_EXTENSION_LENGTH (sizeof (rest_extension) - 1) +/* This is the implicit parameter name when using variable number of + parameters for macros using the ISO C 9x extension. */ +static char va_args_name[] = "__VA_ARGS__"; +#define VA_ARGS_NAME_LENGTH (sizeof (va_args_name) - 1) + /* The structure of a node in the hash table. The hash table has entries for all tokens defined by #define directives (type T_MACRO), plus some special tokens like __LINE__ (these each have their own @@ -1156,12 +1165,15 @@ print_help () printf (" -traditional Follow K&R pre-processor behaviour\n"); printf (" -trigraphs Support ANSI C trigraphs\n"); printf (" -lang-c Assume that the input sources are in C\n"); - printf (" -lang-c89 Assume that the input sources are in C89\n"); + printf (" -lang-c89 Assume that the input is C89; depricated\n"); printf (" -lang-c++ Assume that the input sources are in C++\n"); printf (" -lang-objc Assume that the input sources are in ObjectiveC\n"); printf (" -lang-objc++ Assume that the input sources are in ObjectiveC++\n"); printf (" -lang-asm Assume that the input sources are in assembler\n"); printf (" -lang-chill Assume that the input sources are in Chill\n"); + printf (" -std=<std name> Specify the conformance standard; one of:\n"); + printf (" gnu, c89, c9x, iso9899:1990,\n"); + printf (" iso9899:199409, iso9899:199x\n"); printf (" -+ Allow parsing of C++ style features\n"); printf (" -w Inhibit warning messages\n"); printf (" -Wtrigraphs Warn if trigraphs are encountered\n"); @@ -1460,18 +1472,18 @@ main (argc, argv) case 'l': if (! strcmp (argv[i], "-lang-c")) - cplusplus = 0, cplusplus_comments = 1, c89 = 0, objc = 0; - if (! strcmp (argv[i], "-lang-c89")) - cplusplus = 0, cplusplus_comments = 0, c89 = 1, objc = 0; - if (! strcmp (argv[i], "-lang-c++")) - cplusplus = 1, cplusplus_comments = 1, c89 = 0, objc = 0; - if (! strcmp (argv[i], "-lang-objc")) - cplusplus = 0, cplusplus_comments = 1, c89 = 0, objc = 1; - if (! strcmp (argv[i], "-lang-objc++")) - cplusplus = 1, cplusplus_comments = 1, c89 = 0, objc = 1; - if (! strcmp (argv[i], "-lang-asm")) + cplusplus = 0, cplusplus_comments = 1, c89 = 0, c9x = 1, objc = 0; + else if (! strcmp (argv[i], "-lang-c89")) + cplusplus = 0, cplusplus_comments = 0, c89 = 1, c9x = 0, objc = 0; + else if (! strcmp (argv[i], "-lang-c++")) + cplusplus = 1, cplusplus_comments = 1, c89 = 0, c9x = 0, objc = 0; + else if (! strcmp (argv[i], "-lang-objc")) + cplusplus = 0, cplusplus_comments = 1, c89 = 0, c9x = 0, objc = 1; + else if (! strcmp (argv[i], "-lang-objc++")) + cplusplus = 1, cplusplus_comments = 1, c89 = 0, c9x = 0, objc = 1; + else if (! strcmp (argv[i], "-lang-asm")) lang_asm = 1; - if (! strcmp (argv[i], "-lint")) + else if (! strcmp (argv[i], "-lint")) for_lint = 1; break; @@ -1479,6 +1491,17 @@ main (argc, argv) cplusplus = 1, cplusplus_comments = 1; break; + case 's': + if (!strcmp (argv[i], "-std=iso9899:1990") + || !strcmp (argv[i], "-std=iso9899:199409") + || !strcmp (argv[i], "-std=c89")) + cplusplus = 0, cplusplus_comments = 0, c89 = 1, c9x = 0, objc = 0; + else if (!strcmp (argv[i], "-std=iso9899:199x") + || !strcmp (argv[i], "-std=c9x") + || !strcmp (argv[i], "-std=gnu")) + cplusplus = 0, cplusplus_comments = 1, c89 = 0, c9x = 1, objc = 0; + break; + case 'w': inhibit_warnings = 1; break; @@ -5800,7 +5823,18 @@ create_definition (buf, limit, op) rest_extension); if (!is_idstart[*bp]) + { + if (c9x && limit - bp > (long) REST_EXTENSION_LENGTH + && bcmp (rest_extension, bp, REST_EXTENSION_LENGTH) == 0) + { + /* This is the ISO C 9x way to write macros with variable + number of arguments. */ + rest_args = 1; + temp->rest_args = 1; + } + else pedwarn ("invalid character in macro parameter name"); + } /* Find the end of the arg name. */ while (is_idchar[*bp]) { @@ -5815,6 +5849,13 @@ create_definition (buf, limit, op) break; } } + if (bp == temp->name && rest_args == 1) + { + /* This is the ISO C 9x style. */ + temp->name = va_args_name; + temp->length = VA_ARGS_NAME_LENGTH; + } + else temp->length = bp - temp->name; if (rest_args == 1) bp += REST_EXTENSION_LENGTH; @@ -5828,7 +5869,9 @@ create_definition (buf, limit, op) bp++; SKIP_WHITE_SPACE (bp); /* A comma at this point can only be followed by an identifier. */ - if (!is_idstart[*bp]) { + if (!is_idstart[*bp] + && (c9x && limit - bp <= (long) REST_EXTENSION_LENGTH + || bcmp (rest_extension, bp, REST_EXTENSION_LENGTH) != 0)) { error ("badly punctuated parameter list in `#define'"); goto nope; } @@ -5842,11 +5885,19 @@ create_definition (buf, limit, op) for (otemp = temp->next; otemp != NULL; otemp = otemp->next) if (temp->length == otemp->length - && bcmp (temp->name, otemp->name, temp->length) == 0) { + && bcmp (temp->name, otemp->name, temp->length) == 0) + { error ("duplicate argument name `%.*s' in `#define'", temp->length, temp->name); goto nope; } + if (rest_args == 0 && temp->length == VA_ARGS_NAME_LENGTH + && bcmp (temp->name, va_args_name, VA_ARGS_NAME_LENGTH) == 0) + { + error ("\ +reserved name `%s' used as argument name in `#define'", va_args_name); + goto nope; + } } } |