LEFT | RIGHT |
1 /* Call-backs for C++ error reporting. | 1 /* Call-backs for C++ error reporting. |
2 This code is non-reentrant. | 2 This code is non-reentrant. |
3 Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003, | 3 Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003, |
4 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 | 4 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 |
5 Free Software Foundation, Inc. | 5 Free Software Foundation, Inc. |
6 This file is part of GCC. | 6 This file is part of GCC. |
7 | 7 |
8 GCC is free software; you can redistribute it and/or modify | 8 GCC is free software; you can redistribute it and/or modify |
9 it under the terms of the GNU General Public License as published by | 9 it under the terms of the GNU General Public License as published by |
10 the Free Software Foundation; either version 3, or (at your option) | 10 the Free Software Foundation; either version 3, or (at your option) |
(...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1021 | 1021 |
1022 case NAMESPACE_DECL: | 1022 case NAMESPACE_DECL: |
1023 if (flags & TFF_DECL_SPECIFIERS) | 1023 if (flags & TFF_DECL_SPECIFIERS) |
1024 pp_cxx_declaration (cxx_pp, t); | 1024 pp_cxx_declaration (cxx_pp, t); |
1025 else | 1025 else |
1026 { | 1026 { |
1027 if (! (flags & TFF_UNQUALIFIED_NAME)) | 1027 if (! (flags & TFF_UNQUALIFIED_NAME)) |
1028 dump_scope (CP_DECL_CONTEXT (t), flags); | 1028 dump_scope (CP_DECL_CONTEXT (t), flags); |
1029 flags &= ~TFF_UNQUALIFIED_NAME; | 1029 flags &= ~TFF_UNQUALIFIED_NAME; |
1030 if (DECL_NAME (t) == NULL_TREE) | 1030 if (DECL_NAME (t) == NULL_TREE) |
1031 » pp_cxx_ws_string (cxx_pp, M_("{anonymous}")); | 1031 { |
| 1032 if (!(pp_c_base (cxx_pp)->flags & pp_c_flag_gnu_v3)) |
| 1033 pp_cxx_ws_string (cxx_pp, M_("{anonymous}")); |
| 1034 else |
| 1035 pp_cxx_ws_string (cxx_pp, M_("(anonymous namespace)")); |
| 1036 } |
1032 else | 1037 else |
1033 pp_cxx_tree_identifier (cxx_pp, DECL_NAME (t)); | 1038 pp_cxx_tree_identifier (cxx_pp, DECL_NAME (t)); |
1034 } | 1039 } |
1035 break; | 1040 break; |
1036 | 1041 |
1037 case SCOPE_REF: | 1042 case SCOPE_REF: |
1038 dump_type (TREE_OPERAND (t, 0), flags); | 1043 dump_type (TREE_OPERAND (t, 0), flags); |
1039 pp_string (cxx_pp, "::"); | 1044 pp_string (cxx_pp, "::"); |
1040 dump_decl (TREE_OPERAND (t, 1), flags|TFF_UNQUALIFIED_NAME); | 1045 dump_decl (TREE_OPERAND (t, 1), flags|TFF_UNQUALIFIED_NAME); |
1041 break; | 1046 break; |
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1798 case LABEL_DECL: | 1803 case LABEL_DECL: |
1799 case OVERLOAD: | 1804 case OVERLOAD: |
1800 case TYPE_DECL: | 1805 case TYPE_DECL: |
1801 case IDENTIFIER_NODE: | 1806 case IDENTIFIER_NODE: |
1802 dump_decl (t, ((flags & ~(TFF_DECL_SPECIFIERS|TFF_RETURN_TYPE | 1807 dump_decl (t, ((flags & ~(TFF_DECL_SPECIFIERS|TFF_RETURN_TYPE |
1803 |TFF_TEMPLATE_HEADER)) | 1808 |TFF_TEMPLATE_HEADER)) |
1804 | TFF_NO_FUNCTION_ARGUMENTS)); | 1809 | TFF_NO_FUNCTION_ARGUMENTS)); |
1805 break; | 1810 break; |
1806 | 1811 |
1807 case SSA_NAME: | 1812 case SSA_NAME: |
1808 if (!DECL_ARTIFICIAL (SSA_NAME_VAR (t))) | 1813 if (SSA_NAME_VAR (t) |
| 1814 » && !DECL_ARTIFICIAL (SSA_NAME_VAR (t))) |
1809 dump_expr (SSA_NAME_VAR (t), flags); | 1815 dump_expr (SSA_NAME_VAR (t), flags); |
1810 else | 1816 else |
1811 pp_cxx_ws_string (cxx_pp, M_("<unknown>")); | 1817 pp_cxx_ws_string (cxx_pp, M_("<unknown>")); |
1812 break; | 1818 break; |
1813 | 1819 |
1814 case INTEGER_CST: | 1820 case INTEGER_CST: |
1815 case REAL_CST: | 1821 case REAL_CST: |
1816 case STRING_CST: | 1822 case STRING_CST: |
1817 case COMPLEX_CST: | 1823 case COMPLEX_CST: |
1818 pp_constant (cxx_pp, t); | 1824 pp_constant (cxx_pp, t); |
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2556 | 2562 |
2557 const char * | 2563 const char * |
2558 expr_as_string (tree decl, int flags) | 2564 expr_as_string (tree decl, int flags) |
2559 { | 2565 { |
2560 reinit_cxx_pp (); | 2566 reinit_cxx_pp (); |
2561 pp_translate_identifiers (cxx_pp) = false; | 2567 pp_translate_identifiers (cxx_pp) = false; |
2562 dump_expr (decl, flags); | 2568 dump_expr (decl, flags); |
2563 return pp_formatted_text (cxx_pp); | 2569 return pp_formatted_text (cxx_pp); |
2564 } | 2570 } |
2565 | 2571 |
| 2572 /* Wrap decl_as_string with options appropriate for dwarf. */ |
| 2573 |
| 2574 const char * |
| 2575 decl_as_dwarf_string (tree decl, int flags) |
| 2576 { |
| 2577 const char *name; |
| 2578 /* Curiously, reinit_cxx_pp doesn't reset the flags field, so setting the flag |
| 2579 here will be adequate to get the desired behaviour. */ |
| 2580 pp_c_base (cxx_pp)->flags |= pp_c_flag_gnu_v3; |
| 2581 name = decl_as_string (decl, flags); |
| 2582 /* Subsequent calls to the pretty printer shouldn't use this style. */ |
| 2583 pp_c_base (cxx_pp)->flags &= ~pp_c_flag_gnu_v3; |
| 2584 return name; |
| 2585 } |
| 2586 |
2566 const char * | 2587 const char * |
2567 decl_as_string (tree decl, int flags) | 2588 decl_as_string (tree decl, int flags) |
2568 { | 2589 { |
2569 reinit_cxx_pp (); | 2590 reinit_cxx_pp (); |
2570 pp_translate_identifiers (cxx_pp) = false; | 2591 pp_translate_identifiers (cxx_pp) = false; |
2571 dump_decl (decl, flags); | 2592 dump_decl (decl, flags); |
2572 return pp_formatted_text (cxx_pp); | 2593 return pp_formatted_text (cxx_pp); |
2573 } | 2594 } |
2574 | 2595 |
2575 const char * | 2596 const char * |
2576 decl_as_string_translate (tree decl, int flags) | 2597 decl_as_string_translate (tree decl, int flags) |
2577 { | 2598 { |
2578 reinit_cxx_pp (); | 2599 reinit_cxx_pp (); |
2579 dump_decl (decl, flags); | 2600 dump_decl (decl, flags); |
2580 return pp_formatted_text (cxx_pp); | 2601 return pp_formatted_text (cxx_pp); |
| 2602 } |
| 2603 |
| 2604 /* Wrap lang_decl_name with options appropriate for dwarf. */ |
| 2605 |
| 2606 const char * |
| 2607 lang_decl_dwarf_name (tree decl, int v, bool translate) |
| 2608 { |
| 2609 const char *name; |
| 2610 /* Curiously, reinit_cxx_pp doesn't reset the flags field, so setting the flag |
| 2611 here will be adequate to get the desired behaviour. */ |
| 2612 pp_c_base (cxx_pp)->flags |= pp_c_flag_gnu_v3; |
| 2613 name = lang_decl_name (decl, v, translate); |
| 2614 /* Subsequent calls to the pretty printer shouldn't use this style. */ |
| 2615 pp_c_base (cxx_pp)->flags &= ~pp_c_flag_gnu_v3; |
| 2616 return name; |
2581 } | 2617 } |
2582 | 2618 |
2583 /* Generate the three forms of printable names for cxx_printable_name. */ | 2619 /* Generate the three forms of printable names for cxx_printable_name. */ |
2584 | 2620 |
2585 const char * | 2621 const char * |
2586 lang_decl_name (tree decl, int v, bool translate) | 2622 lang_decl_name (tree decl, int v, bool translate) |
2587 { | 2623 { |
2588 if (v >= 2) | 2624 if (v >= 2) |
2589 return (translate | 2625 return (translate |
2590 ? decl_as_string_translate (decl, TFF_DECL_SPECIFIERS) | 2626 ? decl_as_string_translate (decl, TFF_DECL_SPECIFIERS) |
2591 : decl_as_string (decl, TFF_DECL_SPECIFIERS)); | 2627 : decl_as_string (decl, TFF_DECL_SPECIFIERS)); |
2592 | 2628 |
2593 reinit_cxx_pp (); | 2629 reinit_cxx_pp (); |
2594 pp_translate_identifiers (cxx_pp) = translate; | 2630 pp_translate_identifiers (cxx_pp) = translate; |
2595 if (v == 1 | 2631 if (v == 1 |
2596 && (DECL_CLASS_SCOPE_P (decl) | 2632 && (DECL_CLASS_SCOPE_P (decl) |
2597 || (DECL_NAMESPACE_SCOPE_P (decl) | 2633 || (DECL_NAMESPACE_SCOPE_P (decl) |
2598 && CP_DECL_CONTEXT (decl) != global_namespace))) | 2634 && CP_DECL_CONTEXT (decl) != global_namespace))) |
2599 { | 2635 { |
2600 dump_type (CP_DECL_CONTEXT (decl), TFF_PLAIN_IDENTIFIER); | 2636 dump_type (CP_DECL_CONTEXT (decl), TFF_PLAIN_IDENTIFIER); |
2601 pp_cxx_colon_colon (cxx_pp); | 2637 pp_cxx_colon_colon (cxx_pp); |
2602 } | 2638 } |
2603 | 2639 |
2604 if (TREE_CODE (decl) == FUNCTION_DECL) | 2640 if (TREE_CODE (decl) == FUNCTION_DECL) |
2605 dump_function_name (decl, TFF_PLAIN_IDENTIFIER); | 2641 dump_function_name (decl, TFF_PLAIN_IDENTIFIER); |
| 2642 else if ((DECL_NAME (decl) == NULL_TREE) |
| 2643 && TREE_CODE (decl) == NAMESPACE_DECL) |
| 2644 dump_decl (decl, TFF_PLAIN_IDENTIFIER | TFF_UNQUALIFIED_NAME); |
2606 else | 2645 else |
2607 dump_decl (DECL_NAME (decl), TFF_PLAIN_IDENTIFIER); | 2646 dump_decl (DECL_NAME (decl), TFF_PLAIN_IDENTIFIER); |
2608 | 2647 |
2609 return pp_formatted_text (cxx_pp); | 2648 return pp_formatted_text (cxx_pp); |
2610 } | 2649 } |
2611 | 2650 |
2612 /* Return the location of a tree passed to %+ formats. */ | 2651 /* Return the location of a tree passed to %+ formats. */ |
2613 | 2652 |
2614 location_t | 2653 location_t |
2615 location_of (tree t) | 2654 location_of (tree t) |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3156 record_last_problematic_instantiation (); | 3195 record_last_problematic_instantiation (); |
3157 print_instantiation_full_context (context); | 3196 print_instantiation_full_context (context); |
3158 } | 3197 } |
3159 | 3198 |
3160 /* Report the bare minimum context of a template instantiation. */ | 3199 /* Report the bare minimum context of a template instantiation. */ |
3161 void | 3200 void |
3162 print_instantiation_context (void) | 3201 print_instantiation_context (void) |
3163 { | 3202 { |
3164 print_instantiation_partial_context | 3203 print_instantiation_partial_context |
3165 (global_dc, current_instantiation (), input_location); | 3204 (global_dc, current_instantiation (), input_location); |
| 3205 pp_base_newline (global_dc->printer); |
3166 diagnostic_flush_buffer (global_dc); | 3206 diagnostic_flush_buffer (global_dc); |
3167 } | 3207 } |
3168 | 3208 |
3169 | 3209 |
3170 /* Report what constexpr call(s) we're trying to expand, if any. */ | 3210 /* Report what constexpr call(s) we're trying to expand, if any. */ |
3171 | 3211 |
3172 void | 3212 void |
3173 maybe_print_constexpr_context (diagnostic_context *context) | 3213 maybe_print_constexpr_context (diagnostic_context *context) |
3174 { | 3214 { |
3175 VEC(tree,heap) *call_stack = cx_error_context (); | 3215 VEC(tree,heap) *call_stack = cx_error_context (); |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3401 { | 3441 { |
3402 error_at (location, "%qD is not a member of %qD", name, scope); | 3442 error_at (location, "%qD is not a member of %qD", name, scope); |
3403 suggest_alternatives_for (location, name); | 3443 suggest_alternatives_for (location, name); |
3404 } | 3444 } |
3405 else | 3445 else |
3406 { | 3446 { |
3407 error_at (location, "%<::%D%> has not been declared", name); | 3447 error_at (location, "%<::%D%> has not been declared", name); |
3408 suggest_alternatives_for (location, name); | 3448 suggest_alternatives_for (location, name); |
3409 } | 3449 } |
3410 } | 3450 } |
LEFT | RIGHT |