diff options
| author | Andrey Kotlarski | 2019-01-03 14:07:05 +0200 |
|---|---|---|
| committer | Andrey Kotlarski | 2019-01-03 14:07:05 +0200 |
| commit | e869ae200db8378ab50957b8d357888e78fe0aac (patch) | |
| tree | 9fda78981773b5e5cf7d892345d734b753261a49 /lib-src | |
| parent | f136a4bf7c65894acbf491cad8d5298662ba4cd1 (diff) | |
| download | emacs-e869ae200db8378ab50957b8d357888e78fe0aac.tar.gz emacs-e869ae200db8378ab50957b8d357888e78fe0aac.zip | |
Fix EBROWSE parsing of classes declared final.
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/ebrowse.c | 68 |
1 files changed, 54 insertions, 14 deletions
diff --git a/lib-src/ebrowse.c b/lib-src/ebrowse.c index c91f30cbb60..938b405f3cf 100644 --- a/lib-src/ebrowse.c +++ b/lib-src/ebrowse.c | |||
| @@ -187,7 +187,8 @@ enum token | |||
| 187 | STATIC_CAST, /* static_cast */ | 187 | STATIC_CAST, /* static_cast */ |
| 188 | TYPEID, /* typeid */ | 188 | TYPEID, /* typeid */ |
| 189 | USING, /* using */ | 189 | USING, /* using */ |
| 190 | WCHAR /* wchar_t */ | 190 | WCHAR, /* wchar_t */ |
| 191 | FINAL /* final */ | ||
| 191 | }; | 192 | }; |
| 192 | 193 | ||
| 193 | /* Storage classes, in a wider sense. */ | 194 | /* Storage classes, in a wider sense. */ |
| @@ -471,7 +472,7 @@ static struct sym *add_sym (const char *, struct sym *); | |||
| 471 | static void add_global_defn (char *, char *, int, unsigned, int, int, int); | 472 | static void add_global_defn (char *, char *, int, unsigned, int, int, int); |
| 472 | static void add_global_decl (char *, char *, int, unsigned, int, int, int); | 473 | static void add_global_decl (char *, char *, int, unsigned, int, int, int); |
| 473 | static struct member *add_member (struct sym *, char *, int, int, unsigned); | 474 | static struct member *add_member (struct sym *, char *, int, int, unsigned); |
| 474 | static void class_definition (struct sym *, int, int, int); | 475 | static void class_definition (struct sym *, const char *, int, int, int); |
| 475 | static char *operator_name (int *); | 476 | static char *operator_name (int *); |
| 476 | static void parse_qualified_param_ident_or_type (char **); | 477 | static void parse_qualified_param_ident_or_type (char **); |
| 477 | 478 | ||
| @@ -2035,6 +2036,7 @@ token_string (int t) | |||
| 2035 | case USING: return "using"; | 2036 | case USING: return "using"; |
| 2036 | case WCHAR: return "wchar_t"; | 2037 | case WCHAR: return "wchar_t"; |
| 2037 | case YYEOF: return "EOF"; | 2038 | case YYEOF: return "EOF"; |
| 2039 | case FINAL: return "final"; | ||
| 2038 | 2040 | ||
| 2039 | default: | 2041 | default: |
| 2040 | if (t < 255) | 2042 | if (t < 255) |
| @@ -2140,6 +2142,7 @@ init_scanner (void) | |||
| 2140 | insert_keyword ("explicit", EXPLICIT); | 2142 | insert_keyword ("explicit", EXPLICIT); |
| 2141 | insert_keyword ("extern", EXTERN); | 2143 | insert_keyword ("extern", EXTERN); |
| 2142 | insert_keyword ("false", FALSE); | 2144 | insert_keyword ("false", FALSE); |
| 2145 | insert_keyword ("final", FINAL); | ||
| 2143 | insert_keyword ("float", FLOAT); | 2146 | insert_keyword ("float", FLOAT); |
| 2144 | insert_keyword ("for", FOR); | 2147 | insert_keyword ("for", FOR); |
| 2145 | insert_keyword ("friend", FRIEND); | 2148 | insert_keyword ("friend", FRIEND); |
| @@ -2501,9 +2504,9 @@ member (struct sym *cls, int vis) | |||
| 2501 | char *regexp = NULL; | 2504 | char *regexp = NULL; |
| 2502 | int pos; | 2505 | int pos; |
| 2503 | int is_constructor; | 2506 | int is_constructor; |
| 2504 | int anonymous = 0; | ||
| 2505 | int flags = 0; | 2507 | int flags = 0; |
| 2506 | int class_tag; | 2508 | int class_tag; |
| 2509 | char *class_name; | ||
| 2507 | int type_seen = 0; | 2510 | int type_seen = 0; |
| 2508 | int paren_seen = 0; | 2511 | int paren_seen = 0; |
| 2509 | unsigned hash = 0; | 2512 | unsigned hash = 0; |
| @@ -2626,7 +2629,7 @@ member (struct sym *cls, int vis) | |||
| 2626 | class_tag = LA1; | 2629 | class_tag = LA1; |
| 2627 | type_seen = 1; | 2630 | type_seen = 1; |
| 2628 | MATCH (); | 2631 | MATCH (); |
| 2629 | anonymous = 1; | 2632 | class_name = NULL; |
| 2630 | 2633 | ||
| 2631 | /* More than one ident here to allow for MS-DOS specialties | 2634 | /* More than one ident here to allow for MS-DOS specialties |
| 2632 | like `_export class' etc. The last IDENT seen counts | 2635 | like `_export class' etc. The last IDENT seen counts |
| @@ -2634,14 +2637,33 @@ member (struct sym *cls, int vis) | |||
| 2634 | while (!LOOKING_AT4 (YYEOF, ';', ':', '{')) | 2637 | while (!LOOKING_AT4 (YYEOF, ';', ':', '{')) |
| 2635 | { | 2638 | { |
| 2636 | if (LOOKING_AT (IDENT)) | 2639 | if (LOOKING_AT (IDENT)) |
| 2637 | anonymous = 0; | 2640 | { |
| 2638 | MATCH (); | 2641 | if (class_name) |
| 2642 | { | ||
| 2643 | int size = strlen (yytext); | ||
| 2644 | |||
| 2645 | if(strlen (class_name) < size) | ||
| 2646 | { | ||
| 2647 | class_name = (char *) xrealloc(class_name, size + 1); | ||
| 2648 | } | ||
| 2649 | |||
| 2650 | memcpy(class_name, yytext, size + 1); | ||
| 2651 | } | ||
| 2652 | else | ||
| 2653 | { | ||
| 2654 | class_name = xstrdup(yytext); | ||
| 2655 | } | ||
| 2656 | } | ||
| 2657 | |||
| 2658 | MATCH (); | ||
| 2639 | } | 2659 | } |
| 2640 | 2660 | ||
| 2641 | if (LOOKING_AT2 (':', '{')) | 2661 | if (LOOKING_AT2 (':', '{')) |
| 2642 | class_definition (anonymous ? NULL : cls, class_tag, flags, 1); | 2662 | class_definition (class_name ? cls : NULL, class_name ? class_name : yytext, class_tag, flags, 1); |
| 2643 | else | 2663 | else |
| 2644 | skip_to (';'); | 2664 | skip_to (';'); |
| 2665 | |||
| 2666 | free(class_name); | ||
| 2645 | break; | 2667 | break; |
| 2646 | 2668 | ||
| 2647 | case INT: case CHAR: case LONG: case UNSIGNED: | 2669 | case INT: case CHAR: case LONG: case UNSIGNED: |
| @@ -2997,7 +3019,7 @@ parse_qualified_param_ident_or_type (char **last_id) | |||
| 2997 | Current lookahead is the class name. */ | 3019 | Current lookahead is the class name. */ |
| 2998 | 3020 | ||
| 2999 | static void | 3021 | static void |
| 3000 | class_definition (struct sym *containing, int tag, int flags, int nested) | 3022 | class_definition (struct sym *containing, const char *class_name, int tag, int flags, int nested) |
| 3001 | { | 3023 | { |
| 3002 | struct sym *current; | 3024 | struct sym *current; |
| 3003 | struct sym *base_class; | 3025 | struct sym *base_class; |
| @@ -3009,7 +3031,7 @@ class_definition (struct sym *containing, int tag, int flags, int nested) | |||
| 3009 | current = NULL; | 3031 | current = NULL; |
| 3010 | else | 3032 | else |
| 3011 | { | 3033 | { |
| 3012 | current = add_sym (yytext, containing); | 3034 | current = add_sym (class_name, containing); |
| 3013 | current->pos = BUFFER_POS (); | 3035 | current->pos = BUFFER_POS (); |
| 3014 | current->regexp = matching_regexp (); | 3036 | current->regexp = matching_regexp (); |
| 3015 | current->filename = filename; | 3037 | current->filename = filename; |
| @@ -3292,8 +3314,8 @@ declaration (int flags) | |||
| 3292 | static int | 3314 | static int |
| 3293 | globals (int start_flags) | 3315 | globals (int start_flags) |
| 3294 | { | 3316 | { |
| 3295 | int anonymous; | ||
| 3296 | int class_tk; | 3317 | int class_tk; |
| 3318 | char *class_name; | ||
| 3297 | int flags = start_flags; | 3319 | int flags = start_flags; |
| 3298 | 3320 | ||
| 3299 | for (;;) | 3321 | for (;;) |
| @@ -3362,7 +3384,7 @@ globals (int start_flags) | |||
| 3362 | case CLASS: case STRUCT: case UNION: | 3384 | case CLASS: case STRUCT: case UNION: |
| 3363 | class_tk = LA1; | 3385 | class_tk = LA1; |
| 3364 | MATCH (); | 3386 | MATCH (); |
| 3365 | anonymous = 1; | 3387 | class_name = NULL; |
| 3366 | 3388 | ||
| 3367 | /* More than one ident here to allow for MS-DOS and OS/2 | 3389 | /* More than one ident here to allow for MS-DOS and OS/2 |
| 3368 | specialties like `far', `_Export' etc. Some C++ libs | 3390 | specialties like `far', `_Export' etc. Some C++ libs |
| @@ -3371,19 +3393,37 @@ globals (int start_flags) | |||
| 3371 | while (!LOOKING_AT4 (YYEOF, ';', ':', '{')) | 3393 | while (!LOOKING_AT4 (YYEOF, ';', ':', '{')) |
| 3372 | { | 3394 | { |
| 3373 | if (LOOKING_AT (IDENT)) | 3395 | if (LOOKING_AT (IDENT)) |
| 3374 | anonymous = 0; | 3396 | { |
| 3397 | if (class_name) | ||
| 3398 | { | ||
| 3399 | int size = strlen (yytext); | ||
| 3400 | |||
| 3401 | if(strlen (class_name) < size) | ||
| 3402 | { | ||
| 3403 | class_name = (char *) xrealloc(class_name, size + 1); | ||
| 3404 | } | ||
| 3405 | |||
| 3406 | memcpy(class_name, yytext, size + 1); | ||
| 3407 | } | ||
| 3408 | else | ||
| 3409 | { | ||
| 3410 | class_name = xstrdup(yytext); | ||
| 3411 | } | ||
| 3412 | } | ||
| 3413 | |||
| 3375 | MATCH (); | 3414 | MATCH (); |
| 3376 | } | 3415 | } |
| 3377 | 3416 | ||
| 3378 | /* Don't add anonymous unions. */ | 3417 | /* Don't add anonymous unions. */ |
| 3379 | if (LOOKING_AT2 (':', '{') && !anonymous) | 3418 | if (LOOKING_AT2 (':', '{') && class_name) |
| 3380 | class_definition (NULL, class_tk, flags, 0); | 3419 | class_definition (NULL, class_name, class_tk, flags, 0); |
| 3381 | else | 3420 | else |
| 3382 | { | 3421 | { |
| 3383 | if (skip_to (';') == ';') | 3422 | if (skip_to (';') == ';') |
| 3384 | MATCH (); | 3423 | MATCH (); |
| 3385 | } | 3424 | } |
| 3386 | 3425 | ||
| 3426 | free(class_name); | ||
| 3387 | flags = start_flags; | 3427 | flags = start_flags; |
| 3388 | break; | 3428 | break; |
| 3389 | 3429 | ||