Mercurial > hg > CbC > CbC_gcc
comparison libcpp/lex.c @ 47:3bfb6c00c1e0
update it from 4.4.2 to 4.4.3.
author | kent <kent@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 07 Feb 2010 17:44:34 +0900 |
parents | a06113de4d67 |
children | 77e2b8dfacca |
comparison
equal
deleted
inserted
replaced
46:b85a337e5837 | 47:3bfb6c00c1e0 |
---|---|
502 } | 502 } |
503 | 503 |
504 return false; | 504 return false; |
505 } | 505 } |
506 | 506 |
507 /* Helper function to get the cpp_hashnode of the identifier BASE. */ | |
508 static cpp_hashnode * | |
509 lex_identifier_intern (cpp_reader *pfile, const uchar *base) | |
510 { | |
511 cpp_hashnode *result; | |
512 const uchar *cur; | |
513 unsigned int len; | |
514 unsigned int hash = HT_HASHSTEP (0, *base); | |
515 | |
516 cur = base + 1; | |
517 while (ISIDNUM (*cur)) | |
518 { | |
519 hash = HT_HASHSTEP (hash, *cur); | |
520 cur++; | |
521 } | |
522 len = cur - base; | |
523 hash = HT_HASHFINISH (hash, len); | |
524 result = CPP_HASHNODE (ht_lookup_with_hash (pfile->hash_table, | |
525 base, len, hash, HT_ALLOC)); | |
526 | |
527 /* Rarely, identifiers require diagnostics when lexed. */ | |
528 if (__builtin_expect ((result->flags & NODE_DIAGNOSTIC) | |
529 && !pfile->state.skipping, 0)) | |
530 { | |
531 /* It is allowed to poison the same identifier twice. */ | |
532 if ((result->flags & NODE_POISONED) && !pfile->state.poisoned_ok) | |
533 cpp_error (pfile, CPP_DL_ERROR, "attempt to use poisoned \"%s\"", | |
534 NODE_NAME (result)); | |
535 | |
536 /* Constraint 6.10.3.5: __VA_ARGS__ should only appear in the | |
537 replacement list of a variadic macro. */ | |
538 if (result == pfile->spec_nodes.n__VA_ARGS__ | |
539 && !pfile->state.va_args_ok) | |
540 cpp_error (pfile, CPP_DL_PEDWARN, | |
541 "__VA_ARGS__ can only appear in the expansion" | |
542 " of a C99 variadic macro"); | |
543 } | |
544 | |
545 return result; | |
546 } | |
547 | |
548 /* Get the cpp_hashnode of an identifier specified by NAME in | |
549 the current cpp_reader object. If none is found, NULL is returned. */ | |
550 cpp_hashnode * | |
551 _cpp_lex_identifier (cpp_reader *pfile, const char *name) | |
552 { | |
553 cpp_hashnode *result; | |
554 result = lex_identifier_intern (pfile, (uchar *) name); | |
555 return result; | |
556 } | |
557 | |
507 /* Lex an identifier starting at BUFFER->CUR - 1. */ | 558 /* Lex an identifier starting at BUFFER->CUR - 1. */ |
508 static cpp_hashnode * | 559 static cpp_hashnode * |
509 lex_identifier (cpp_reader *pfile, const uchar *base, bool starts_ucn, | 560 lex_identifier (cpp_reader *pfile, const uchar *base, bool starts_ucn, |
510 struct normalize_state *nst) | 561 struct normalize_state *nst) |
511 { | 562 { |