diff options
author | Jeffrey A Law <law@cygnus.com> | 1999-01-27 01:43:17 +0000 |
---|---|---|
committer | Jeff Law <law@gcc.gnu.org> | 1999-01-26 18:43:17 -0700 |
commit | ab87f8c8d19d6b0954516d7f1d8733f42076be81 (patch) | |
tree | e7daf0f28ecb5da9660b21aee68e6919f846c183 /gcc/cexp.c | |
parent | 01b4cf2b7a1fe9a3f6f070217be5f93854c54545 (diff) | |
download | gcc-ab87f8c8d19d6b0954516d7f1d8733f42076be81.zip gcc-ab87f8c8d19d6b0954516d7f1d8733f42076be81.tar.gz gcc-ab87f8c8d19d6b0954516d7f1d8733f42076be81.tar.bz2 |
Merge in gcc2 snapshot 19980929. See gcc/ChangeLog and gcc/FSFChangeLog for
details.
From-SVN: r24879
Diffstat (limited to 'gcc/cexp.c')
-rw-r--r-- | gcc/cexp.c | 193 |
1 files changed, 98 insertions, 95 deletions
@@ -23,10 +23,6 @@ #include "config.h" -#define PRINTF_PROTO(ARGS, m, n) PVPROTO (ARGS) ATTRIBUTE_PRINTF(m, n) - -#define PRINTF_PROTO_1(ARGS) PRINTF_PROTO(ARGS, 1, 2) - #include "system.h" #include <setjmp.h> /* #define YYDEBUG 1 */ @@ -82,7 +78,7 @@ struct arglist { HOST_WIDE_INT parse_c_expression PROTO((char *, int)); static int yylex PROTO((void)); -static void yyerror PROTO((char *)) __attribute__ ((noreturn)); +static void yyerror PRINTF_PROTO_1((char *, ...)) __attribute__ ((noreturn)); static HOST_WIDE_INT expression_value; #ifdef TEST_EXP_READER static int expression_signedp; @@ -180,7 +176,7 @@ static void integer_overflow PROTO((void)); #define SIGNED (~0) #define UNSIGNED 0 -#line 188 "cexp.y" +#line 184 "cexp.y" typedef union { struct constant {HOST_WIDE_INT value; int signedp;} integer; struct name {U_CHAR *address; int length;} name; @@ -261,10 +257,10 @@ static const short yyrhs[] = { 35, #if YYDEBUG != 0 static const short yyrline[] = { 0, - 218, 228, 229, 236, 241, 244, 246, 249, 253, 255, - 260, 265, 278, 295, 308, 314, 320, 326, 332, 335, - 338, 345, 352, 359, 366, 369, 372, 375, 378, 381, - 384, 387, 389, 392, 395, 397, 399, 407, 409, 422 + 214, 224, 225, 232, 237, 240, 242, 245, 249, 251, + 256, 261, 274, 291, 304, 310, 316, 322, 328, 331, + 334, 341, 348, 355, 362, 365, 368, 371, 374, 377, + 380, 383, 385, 388, 391, 393, 395, 403, 405, 418 }; #endif @@ -370,7 +366,7 @@ static const short yycheck[] = { 4, 26, 27, 23, 24, 25, 26, 27, 0, 9 }; /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ -#line 3 "/usr/cygnus/gnupro-98r1/share/bison.simple" +#line 3 "/usr/lib/bison.simple" /* Skeleton output parser for bison, Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. @@ -387,8 +383,7 @@ static const short yycheck[] = { 4, You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* As a special exception, when this file is copied by Bison into a Bison output file, you may use that output file without restriction. @@ -564,7 +559,7 @@ __yy_memcpy (char *to, char *from, int count) #endif #endif -#line 196 "/usr/cygnus/gnupro-98r1/share/bison.simple" +#line 196 "/usr/lib/bison.simple" /* The user can define YYPARSE_PARAM as the name of an argument to be passed into yyparse. The argument should have type void *. @@ -869,7 +864,7 @@ yyreduce: switch (yyn) { case 1: -#line 219 "cexp.y" +#line 215 "cexp.y" { expression_value = yyvsp[0].integer.value; #ifdef TEST_EXP_READER @@ -878,55 +873,55 @@ case 1: ; break;} case 3: -#line 230 "cexp.y" +#line 226 "cexp.y" { if (pedantic) pedwarn ("comma operator in operand of `#if'"); yyval.integer = yyvsp[0].integer; ; break;} case 4: -#line 237 "cexp.y" +#line 233 "cexp.y" { yyval.integer.value = - yyvsp[0].integer.value; yyval.integer.signedp = yyvsp[0].integer.signedp; if ((yyval.integer.value & yyvsp[0].integer.value & yyval.integer.signedp) < 0) integer_overflow (); ; break;} case 5: -#line 242 "cexp.y" +#line 238 "cexp.y" { yyval.integer.value = ! yyvsp[0].integer.value; yyval.integer.signedp = SIGNED; ; break;} case 6: -#line 245 "cexp.y" +#line 241 "cexp.y" { yyval.integer = yyvsp[0].integer; ; break;} case 7: -#line 247 "cexp.y" +#line 243 "cexp.y" { yyval.integer.value = ~ yyvsp[0].integer.value; yyval.integer.signedp = yyvsp[0].integer.signedp; ; break;} case 8: -#line 250 "cexp.y" +#line 246 "cexp.y" { yyval.integer.value = check_assertion (yyvsp[0].name.address, yyvsp[0].name.length, 0, NULL_PTR); yyval.integer.signedp = SIGNED; ; break;} case 9: -#line 254 "cexp.y" +#line 250 "cexp.y" { keyword_parsing = 1; ; break;} case 10: -#line 256 "cexp.y" +#line 252 "cexp.y" { yyval.integer.value = check_assertion (yyvsp[-4].name.address, yyvsp[-4].name.length, 1, yyvsp[-1].keywords); keyword_parsing = 0; yyval.integer.signedp = SIGNED; ; break;} case 11: -#line 261 "cexp.y" +#line 257 "cexp.y" { yyval.integer = yyvsp[-1].integer; ; break;} case 12: -#line 266 "cexp.y" +#line 262 "cexp.y" { yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp; if (yyval.integer.signedp) { @@ -941,7 +936,7 @@ case 12: * yyvsp[0].integer.value); ; break;} case 13: -#line 279 "cexp.y" +#line 275 "cexp.y" { if (yyvsp[0].integer.value == 0) { if (!skip_evaluation) @@ -960,7 +955,7 @@ case 13: / yyvsp[0].integer.value); ; break;} case 14: -#line 296 "cexp.y" +#line 292 "cexp.y" { if (yyvsp[0].integer.value == 0) { if (!skip_evaluation) @@ -975,7 +970,7 @@ case 14: % yyvsp[0].integer.value); ; break;} case 15: -#line 309 "cexp.y" +#line 305 "cexp.y" { yyval.integer.value = yyvsp[-2].integer.value + yyvsp[0].integer.value; yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp; if (overflow_sum_sign (yyvsp[-2].integer.value, yyvsp[0].integer.value, @@ -983,7 +978,7 @@ case 15: integer_overflow (); ; break;} case 16: -#line 315 "cexp.y" +#line 311 "cexp.y" { yyval.integer.value = yyvsp[-2].integer.value - yyvsp[0].integer.value; yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp; if (overflow_sum_sign (yyval.integer.value, yyvsp[0].integer.value, @@ -991,7 +986,7 @@ case 16: integer_overflow (); ; break;} case 17: -#line 321 "cexp.y" +#line 317 "cexp.y" { yyval.integer.signedp = yyvsp[-2].integer.signedp; if ((yyvsp[0].integer.value & yyvsp[0].integer.signedp) < 0) yyval.integer.value = right_shift (&yyvsp[-2].integer, -yyvsp[0].integer.value); @@ -999,7 +994,7 @@ case 17: yyval.integer.value = left_shift (&yyvsp[-2].integer, yyvsp[0].integer.value); ; break;} case 18: -#line 327 "cexp.y" +#line 323 "cexp.y" { yyval.integer.signedp = yyvsp[-2].integer.signedp; if ((yyvsp[0].integer.value & yyvsp[0].integer.signedp) < 0) yyval.integer.value = left_shift (&yyvsp[-2].integer, -yyvsp[0].integer.value); @@ -1007,17 +1002,17 @@ case 18: yyval.integer.value = right_shift (&yyvsp[-2].integer, yyvsp[0].integer.value); ; break;} case 19: -#line 333 "cexp.y" +#line 329 "cexp.y" { yyval.integer.value = (yyvsp[-2].integer.value == yyvsp[0].integer.value); yyval.integer.signedp = SIGNED; ; break;} case 20: -#line 336 "cexp.y" +#line 332 "cexp.y" { yyval.integer.value = (yyvsp[-2].integer.value != yyvsp[0].integer.value); yyval.integer.signedp = SIGNED; ; break;} case 21: -#line 339 "cexp.y" +#line 335 "cexp.y" { yyval.integer.signedp = SIGNED; if (yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp) yyval.integer.value = yyvsp[-2].integer.value <= yyvsp[0].integer.value; @@ -1026,7 +1021,7 @@ case 21: <= yyvsp[0].integer.value); ; break;} case 22: -#line 346 "cexp.y" +#line 342 "cexp.y" { yyval.integer.signedp = SIGNED; if (yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp) yyval.integer.value = yyvsp[-2].integer.value >= yyvsp[0].integer.value; @@ -1035,7 +1030,7 @@ case 22: >= yyvsp[0].integer.value); ; break;} case 23: -#line 353 "cexp.y" +#line 349 "cexp.y" { yyval.integer.signedp = SIGNED; if (yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp) yyval.integer.value = yyvsp[-2].integer.value < yyvsp[0].integer.value; @@ -1044,7 +1039,7 @@ case 23: < yyvsp[0].integer.value); ; break;} case 24: -#line 360 "cexp.y" +#line 356 "cexp.y" { yyval.integer.signedp = SIGNED; if (yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp) yyval.integer.value = yyvsp[-2].integer.value > yyvsp[0].integer.value; @@ -1053,64 +1048,64 @@ case 24: > yyvsp[0].integer.value); ; break;} case 25: -#line 367 "cexp.y" +#line 363 "cexp.y" { yyval.integer.value = yyvsp[-2].integer.value & yyvsp[0].integer.value; yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp; ; break;} case 26: -#line 370 "cexp.y" +#line 366 "cexp.y" { yyval.integer.value = yyvsp[-2].integer.value ^ yyvsp[0].integer.value; yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp; ; break;} case 27: -#line 373 "cexp.y" +#line 369 "cexp.y" { yyval.integer.value = yyvsp[-2].integer.value | yyvsp[0].integer.value; yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp; ; break;} case 28: -#line 376 "cexp.y" +#line 372 "cexp.y" { skip_evaluation += !yyvsp[-1].integer.value; ; break;} case 29: -#line 378 "cexp.y" +#line 374 "cexp.y" { skip_evaluation -= !yyvsp[-3].integer.value; yyval.integer.value = (yyvsp[-3].integer.value && yyvsp[0].integer.value); yyval.integer.signedp = SIGNED; ; break;} case 30: -#line 382 "cexp.y" +#line 378 "cexp.y" { skip_evaluation += !!yyvsp[-1].integer.value; ; break;} case 31: -#line 384 "cexp.y" +#line 380 "cexp.y" { skip_evaluation -= !!yyvsp[-3].integer.value; yyval.integer.value = (yyvsp[-3].integer.value || yyvsp[0].integer.value); yyval.integer.signedp = SIGNED; ; break;} case 32: -#line 388 "cexp.y" +#line 384 "cexp.y" { skip_evaluation += !yyvsp[-1].integer.value; ; break;} case 33: -#line 390 "cexp.y" +#line 386 "cexp.y" { skip_evaluation += !!yyvsp[-4].integer.value - !yyvsp[-4].integer.value; ; break;} case 34: -#line 392 "cexp.y" +#line 388 "cexp.y" { skip_evaluation -= !!yyvsp[-6].integer.value; yyval.integer.value = yyvsp[-6].integer.value ? yyvsp[-3].integer.value : yyvsp[0].integer.value; yyval.integer.signedp = yyvsp[-3].integer.signedp & yyvsp[0].integer.signedp; ; break;} case 35: -#line 396 "cexp.y" +#line 392 "cexp.y" { yyval.integer = yylval.integer; ; break;} case 36: -#line 398 "cexp.y" +#line 394 "cexp.y" { yyval.integer = yylval.integer; ; break;} case 37: -#line 400 "cexp.y" +#line 396 "cexp.y" { if (warn_undef && !skip_evaluation) warning ("`%.*s' is not defined", yyvsp[0].name.length, yyvsp[0].name.address); @@ -1118,11 +1113,11 @@ case 37: yyval.integer.signedp = SIGNED; ; break;} case 38: -#line 408 "cexp.y" +#line 404 "cexp.y" { yyval.keywords = 0; ; break;} case 39: -#line 410 "cexp.y" +#line 406 "cexp.y" { struct arglist *temp; yyval.keywords = (struct arglist *) xmalloc (sizeof (struct arglist)); yyval.keywords->next = yyvsp[-2].keywords; @@ -1137,7 +1132,7 @@ case 39: temp->next->length = 1; ; break;} case 40: -#line 423 "cexp.y" +#line 419 "cexp.y" { yyval.keywords = (struct arglist *) xmalloc (sizeof (struct arglist)); yyval.keywords->name = yyvsp[-1].name.address; yyval.keywords->length = yyvsp[-1].name.length; @@ -1145,7 +1140,7 @@ case 40: break;} } /* the action file gets copied in in place of this dollarsign */ -#line 498 "/usr/cygnus/gnupro-98r1/share/bison.simple" +#line 498 "/usr/lib/bison.simple" yyvsp -= yylen; yyssp -= yylen; @@ -1341,7 +1336,7 @@ yyerrhandle: yystate = yyn; goto yynewstate; } -#line 428 "cexp.y" +#line 424 "cexp.y" /* During parsing of a C expression, the pointer to the next character @@ -1408,12 +1403,9 @@ parse_number (olen) else { if (c == '.' || c == 'e' || c == 'E' || c == 'p' || c == 'P') yyerror ("Floating point numbers not allowed in #if expressions"); - else { - char *buf = (char *) alloca (p - lexptr + 40); - sprintf (buf, "missing white space after number `%.*s'", + else + yyerror ("missing white space after number `%.*s'", (int) (p - lexptr - 1), lexptr); - yyerror (buf); - } } if (--len == 0) @@ -1490,11 +1482,7 @@ yylex () if (c == *toktab->operator && tokstart[1] == toktab->operator[1]) { lexptr += 2; if (toktab->token == ERROR) - { - char *buf = (char *) alloca (40); - sprintf (buf, "`%s' not allowed in operand of `#if'", toktab->operator); - yyerror (buf); - } + yyerror ("`%s' not allowed in operand of `#if'", toktab->operator); return toktab->token; } @@ -1894,15 +1882,6 @@ parse_escape (string_ptr, result_mask) } static void -yyerror (s) - char *s; -{ - error ("%s", s); - skip_evaluation = 0; - longjmp (parse_return_error, 1); -} - -static void integer_overflow () { if (!skip_evaluation && pedantic) @@ -1968,6 +1947,29 @@ parse_c_expression (string, warn_undefined) return expression_value; /* set by yyparse () */ } + +static void +yyerror VPROTO ((char * msgid, ...)) +{ +#ifndef ANSI_PROTOTYPES + char * msgid; +#endif + va_list args; + + VA_START (args, msgid); + +#ifndef ANSI_PROTOTYPES + msgid = va_arg (args, char *); +#endif + + fprintf (stderr, "error: "); + vfprintf (stderr, _(msgid), args); + fprintf (stderr, "\n"); + va_end (args); + skip_evaluation = 0; + longjmp (parse_return_error, 1); +} + #ifdef TEST_EXP_READER @@ -2078,65 +2080,66 @@ initialize_random_junk () } void -error VPROTO ((char * msg, ...)) +error VPROTO ((char * msgid, ...)) { #ifndef ANSI_PROTOTYPES - char * msg; + char * msgid; #endif va_list args; - VA_START (args, msg); - + VA_START (args, msgid); + #ifndef ANSI_PROTOTYPES - msg = va_arg (args, char *); + msgid = va_arg (args, char *); #endif - + fprintf (stderr, "error: "); - vfprintf (stderr, msg, args); + vfprintf (stderr, _(msgid), args); fprintf (stderr, "\n"); va_end (args); } void -pedwarn VPROTO ((char * msg, ...)) +pedwarn VPROTO ((char * msgid, ...)) { #ifndef ANSI_PROTOTYPES - char * msg; + char * msgid; #endif va_list args; - VA_START (args, msg); - + VA_START (args, msgid); + #ifndef ANSI_PROTOTYPES - msg = va_arg (args, char *); + msgid = va_arg (args, char *); #endif - + fprintf (stderr, "pedwarn: "); - vfprintf (stderr, msg, args); + vfprintf (stderr, _(msgid), args); fprintf (stderr, "\n"); va_end (args); } void -warning VPROTO ((char * msg, ...)) +warning VPROTO ((char * msgid, ...)) { #ifndef ANSI_PROTOTYPES - char * msg; + char * msgid; #endif va_list args; - VA_START (args, msg); - + VA_START (args, msgid); + #ifndef ANSI_PROTOTYPES - msg = va_arg (args, char *); + msgid = va_arg (args, char *); #endif - + fprintf (stderr, "warning: "); - vfprintf (stderr, msg, args); + vfprintf (stderr, _(msgid), args); fprintf (stderr, "\n"); va_end (args); } + int check_assertion (name, sym_length, tokens_specified, tokens) U_CHAR *name; |