diff options
author | Jason Merrill <jason@redhat.com> | 2022-10-31 11:36:05 -0400 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2022-10-31 22:13:08 -0400 |
commit | 2031dff9d921dbec9065c5b7d3ef3ac97adf18b2 (patch) | |
tree | d8f71d4b60c14615e9184e4309cd313154fb184c | |
parent | f5a360ff9bab5eb255ae86685f25c3e22fcfc554 (diff) | |
download | gcc-2031dff9d921dbec9065c5b7d3ef3ac97adf18b2.zip gcc-2031dff9d921dbec9065c5b7d3ef3ac97adf18b2.tar.gz gcc-2031dff9d921dbec9065c5b7d3ef3ac97adf18b2.tar.bz2 |
c++: more tidying
gcc/cp/ChangeLog:
* contracts.h: Move lots of decls from...
* cp-tree.h: ...here.
* contracts.cc (cp_contract_assertion_p): Move from parser.cc.
(inherit_base_contracts): Move from search.cc.
* decl.cc (grokdeclarator): Don't use function_declarator_p.
* decl2.cc (cp_tree_defined_p_r)
(cp_tree_defined_p): Remove.
* module.cc (trees_out::fn_parms_init): Tweak comment.
* parser.cc (cp_contract_assertion_p): Moved.
(find_innermost_function_declarator)
(function_declarator_p): Revert.
(cp_parser_function_definition_after_declarator): Remove dead assignment.
(cp_parser_save_default_args): Tweak formatting.
* search.cc (inherit_base_contracts): Moved.
gcc/ChangeLog:
* input.cc (get_source): Tweak comments.
-rw-r--r-- | gcc/cp/contracts.cc | 43 | ||||
-rw-r--r-- | gcc/cp/contracts.h | 94 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 140 | ||||
-rw-r--r-- | gcc/cp/decl.cc | 10 | ||||
-rw-r--r-- | gcc/cp/decl2.cc | 22 | ||||
-rw-r--r-- | gcc/cp/module.cc | 2 | ||||
-rw-r--r-- | gcc/cp/parser.cc | 48 | ||||
-rw-r--r-- | gcc/cp/search.cc | 32 | ||||
-rw-r--r-- | gcc/input.cc | 6 |
9 files changed, 180 insertions, 217 deletions
diff --git a/gcc/cp/contracts.cc b/gcc/cp/contracts.cc index 272448d..6732b76 100644 --- a/gcc/cp/contracts.cc +++ b/gcc/cp/contracts.cc @@ -848,6 +848,17 @@ cxx_contract_attribute_p (const_tree attr) || TREE_CODE (TREE_VALUE (TREE_VALUE (attr))) == ASSERTION_STMT); } +/* True if ATTR is an assertion. */ + +bool +cp_contract_assertion_p (const_tree attr) +{ + /* This is only an assertion if it is a valid cxx contract attribute and the + statement is an ASSERTION_STMT. */ + return cxx_contract_attribute_p (attr) + && TREE_CODE (CONTRACT_STATEMENT (attr)) == ASSERTION_STMT; +} + /* Remove all c++2a style contract attributes from the DECL_ATTRIBUTEs of the FUNCTION_DECL FNDECL. */ @@ -2188,4 +2199,36 @@ duplicate_contracts (tree newdecl, tree olddecl) } } +/* Replace the any contract attributes on OVERRIDER with a copy where any + references to BASEFN's PARM_DECLs have been rewritten to the corresponding + PARM_DECL in OVERRIDER. */ + +void +inherit_base_contracts (tree overrider, tree basefn) +{ + tree last = NULL_TREE, contract_attrs = NULL_TREE; + for (tree a = DECL_CONTRACTS (basefn); + a != NULL_TREE; + a = CONTRACT_CHAIN (a)) + { + tree c = copy_node (a); + TREE_VALUE (c) = build_tree_list (TREE_PURPOSE (TREE_VALUE (c)), + copy_node (CONTRACT_STATEMENT (c))); + + tree src = basefn; + tree dst = overrider; + remap_contract (src, dst, CONTRACT_STATEMENT (c), /*duplicate_p=*/true); + + CONTRACT_COMMENT (CONTRACT_STATEMENT (c)) = + copy_node (CONTRACT_COMMENT (CONTRACT_STATEMENT (c))); + + chainon (last, c); + last = c; + if (!contract_attrs) + contract_attrs = c; + } + + set_decl_contracts (overrider, contract_attrs); +} + #include "gt-cp-contracts.h" diff --git a/gcc/cp/contracts.h b/gcc/cp/contracts.h index 81b5283..ec48a04 100644 --- a/gcc/cp/contracts.h +++ b/gcc/cp/contracts.h @@ -1,6 +1,6 @@ /* Definitions for C++ contract levels. Implements functionality described in the N4820 working draft version of contracts, P1290, P1332, and P1429. - Copyright (C) 2020 Free Software Foundation, Inc. + Copyright (C) 2020-2022 Free Software Foundation, Inc. Contributed by Jeff Chapman II (jchapman@lock3software.com) This file is part of GCC. @@ -147,6 +147,7 @@ extern contract_level map_contract_level (const char *); /* Check if an attribute is a cxx contract attribute. */ extern bool cxx_contract_attribute_p (const_tree); +extern bool cp_contract_assertion_p (const_tree); /* Returns the default role. */ @@ -163,4 +164,95 @@ extern void handle_OPT_fcontract_continuation_mode_ (const char *); extern void handle_OPT_fcontract_role_ (const char *); extern void handle_OPT_fcontract_semantic_ (const char *); +enum contract_matching_context +{ + cmc_declaration, + cmc_override +}; + +/* True iff the FUNCTION_DECL NODE currently has any contracts. */ +#define DECL_HAS_CONTRACTS_P(NODE) \ + (DECL_CONTRACTS (NODE) != NULL_TREE) + +/* For a FUNCTION_DECL of a guarded function, this points to a list of the pre + and post contracts of the first decl of NODE in original order. */ +#define DECL_CONTRACTS(NODE) \ + (find_contract (DECL_ATTRIBUTES (NODE))) + +/* The next contract (if any) after this one in an attribute list. */ +#define CONTRACT_CHAIN(NODE) \ + (find_contract (TREE_CHAIN (NODE))) + +/* The wrapper of the original source location of a list of contracts. */ +#define CONTRACT_SOURCE_LOCATION_WRAPPER(NODE) \ + (TREE_PURPOSE (TREE_VALUE (NODE))) + +/* The original source location of a list of contracts. */ +#define CONTRACT_SOURCE_LOCATION(NODE) \ + (EXPR_LOCATION (CONTRACT_SOURCE_LOCATION_WRAPPER (NODE))) + +/* The actual code _STMT for a contract attribute. */ +#define CONTRACT_STATEMENT(NODE) \ + (TREE_VALUE (TREE_VALUE (NODE))) + +/* For a FUNCTION_DECL of a guarded function, this holds the function decl + where pre contract checks are emitted. */ +#define DECL_PRE_FN(NODE) \ + (get_precondition_function ((NODE))) + +/* For a FUNCTION_DECL of a guarded function, this holds the function decl + where post contract checks are emitted. */ +#define DECL_POST_FN(NODE) \ + (get_postcondition_function ((NODE))) + +/* For a FUNCTION_DECL of a pre/post function, this points back to the + original guarded function. */ +#define DECL_ORIGINAL_FN(NODE) \ + (DECL_ABSTRACT_ORIGIN (NODE)) + +/* True iff the FUNCTION_DECL is the pre function for a guarded function. */ +#define DECL_IS_PRE_FN_P(NODE) \ + (DECL_ORIGINAL_FN (NODE) && DECL_PRE_FN (DECL_ORIGINAL_FN (NODE)) == NODE) + +/* True iff the FUNCTION_DECL is the post function for a guarded function. */ +#define DECL_IS_POST_FN_P(NODE) \ + (DECL_ORIGINAL_FN (NODE) && DECL_POST_FN (DECL_ORIGINAL_FN (NODE)) == NODE) + +extern tree invalidate_contract (tree); +extern tree finish_contract_attribute (tree, tree); +extern void update_late_contract (tree, tree, tree); +extern void remove_contract_attributes (tree); +extern void copy_contract_attributes (tree, tree); +extern tree splice_out_contracts (tree); +extern bool check_postcondition_result (tree, tree, location_t); +extern void rebuild_postconditions (tree); +extern bool match_contract_conditions (location_t, tree, location_t, tree, contract_matching_context); +extern void defer_guarded_contract_match (tree, tree, tree); +extern void match_deferred_contracts (tree); +extern void remap_contract (tree, tree, tree, bool); +extern void remap_contracts (tree, tree, tree, bool); +extern void remap_dummy_this (tree, tree *); +extern bool contract_active_p (tree); +extern bool contract_any_active_p (tree); +extern bool contract_any_deferred_p (tree); +extern bool all_attributes_are_contracts_p (tree); +extern void build_contract_function_decls (tree); +extern void set_contract_functions (tree, tree, tree); +extern tree start_postcondition_statement (); +extern void finish_postcondition_statement (tree); +extern tree build_contract_check (tree); +extern tree get_postcondition_result_parameter (tree); +extern tree get_precondition_function (tree); +extern tree get_postcondition_function (tree); +extern tree get_contracts_original_fn (tree); +extern void emit_assertion (tree); +extern void emit_preconditions (tree); +extern void emit_postconditions_cleanup (tree); +extern void maybe_update_postconditions (tree); +extern void start_function_contracts (tree); +extern void finish_function_contracts (tree); +extern tree apply_postcondition_to_return (tree); +extern void duplicate_contracts (tree, tree); +extern void inherit_base_contracts (tree, tree); + #endif /* ! GCC_CP_CONTRACT_H */ diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index a212aa2..4b5d14f 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -3747,64 +3747,6 @@ struct GTY(()) lang_decl { #define DECL_PENDING_INLINE_INFO(NODE) \ (LANG_DECL_FN_CHECK (NODE)->u.pending_inline_info) -/* Return the first contract in ATTRS, or NULL_TREE if there are none. */ - -inline tree -find_contract (tree attrs) -{ - while (attrs && !cxx_contract_attribute_p (attrs)) - attrs = TREE_CHAIN (attrs); - return attrs; -} - -/* True iff the FUNCTION_DECL NODE currently has any contracts. */ -#define DECL_HAS_CONTRACTS_P(NODE) \ - (DECL_CONTRACTS (NODE) != NULL_TREE) - -/* For a FUNCTION_DECL of a guarded function, this points to a list of the pre - and post contracts of the first decl of NODE in original order. */ -#define DECL_CONTRACTS(NODE) \ - (find_contract (DECL_ATTRIBUTES (NODE))) - -/* The next contract (if any) after this one in an attribute list. */ -#define CONTRACT_CHAIN(NODE) \ - (find_contract (TREE_CHAIN (NODE))) - -/* The wrapper of the original source location of a list of contracts. */ -#define CONTRACT_SOURCE_LOCATION_WRAPPER(NODE) \ - (TREE_PURPOSE (TREE_VALUE (NODE))) - -/* The original source location of a list of contracts. */ -#define CONTRACT_SOURCE_LOCATION(NODE) \ - (EXPR_LOCATION (CONTRACT_SOURCE_LOCATION_WRAPPER (NODE))) - -/* The actual code _STMT for a contract attribute. */ -#define CONTRACT_STATEMENT(NODE) \ - (TREE_VALUE (TREE_VALUE (NODE))) - -/* For a FUNCTION_DECL of a guarded function, this holds the function decl - where pre contract checks are emitted. */ -#define DECL_PRE_FN(NODE) \ - (get_precondition_function ((NODE))) - -/* For a FUNCTION_DECL of a guarded function, this holds the function decl - where post contract checks are emitted. */ -#define DECL_POST_FN(NODE) \ - (get_postcondition_function ((NODE))) - -/* For a FUNCTION_DECL of a pre/post function, this points back to the - original guarded function. */ -#define DECL_ORIGINAL_FN(NODE) \ - (DECL_ABSTRACT_ORIGIN (NODE)) - -/* True iff the FUNCTION_DECL is the pre function for a guarded function. */ -#define DECL_IS_PRE_FN_P(NODE) \ - (DECL_ORIGINAL_FN (NODE) && DECL_PRE_FN (DECL_ORIGINAL_FN (NODE)) == NODE) - -/* True iff the FUNCTION_DECL is the post function for a guarded function. */ -#define DECL_IS_POST_FN_P(NODE) \ - (DECL_ORIGINAL_FN (NODE) && DECL_POST_FN (DECL_ORIGINAL_FN (NODE)) == NODE) - /* Nonzero for TYPE_DECL means that it was written 'using name = type'. */ #define TYPE_DECL_ALIAS_P(NODE) \ DECL_LANG_FLAG_6 (TYPE_DECL_CHECK (NODE)) @@ -7146,7 +7088,6 @@ extern void import_export_decl (tree); extern tree build_cleanup (tree); extern tree build_offset_ref_call_from_tree (tree, vec<tree, va_gc> **, tsubst_flags_t); -extern bool cp_tree_defined_p (tree); extern bool decl_defined_p (tree); extern bool decl_constant_var_p (tree); extern bool decl_maybe_constant_var_p (tree); @@ -7458,8 +7399,6 @@ extern location_t defparse_location (tree); extern void maybe_show_extern_c_location (void); extern bool literal_integer_zerop (const_tree); extern tree attr_chainon (tree, tree); -extern bool function_declarator_p (const cp_declarator *); -extern const cp_declarator *find_innermost_function_declarator (const cp_declarator *); /* in pt.cc */ extern tree canonical_type_parameter (tree); @@ -7741,62 +7680,6 @@ extern bool perform_or_defer_access_check (tree, tree, tree, tsubst_flags_t, access_failure_info *afi = NULL); -/* contracts.cc */ -enum contract_matching_context -{ - cmc_declaration, - cmc_override -}; - -extern void init_contract_processing (); -extern tree invalidate_contract (tree); -extern tree make_postcondition_variable (cp_expr); -extern tree make_postcondition_variable (cp_expr, tree); -extern bool check_postcondition_result (tree, tree, location_t); -extern void rebuild_postconditions (tree); -extern tree grok_contract (tree, tree, tree, cp_expr, location_t); -extern tree finish_contract_attribute (tree, tree); -extern void update_late_contract (tree, tree, tree); -extern tree finish_contract_condition (cp_expr); -extern void remove_contract_attributes (tree); -extern void copy_contract_attributes (tree, tree); -extern tree splice_out_contracts (tree); -extern bool match_contract_conditions (location_t, tree, location_t, tree, contract_matching_context); -extern void defer_guarded_contract_match (tree, tree, tree); -extern void match_deferred_contracts (tree); -extern void remap_contract (tree, tree, tree, bool); -extern void remap_contracts (tree, tree, tree, bool); -extern void remap_dummy_this (tree, tree *); -extern bool contract_active_p (tree); -extern bool contract_any_active_p (tree); -extern bool contract_any_deferred_p (tree); -extern bool all_attributes_are_contracts_p (tree); -extern void build_contract_function_decls (tree); -extern void set_contract_functions (tree, tree, tree); -extern tree start_postcondition_statement (); -extern void finish_postcondition_statement (tree); -extern tree build_contract_check (tree); -extern tree get_postcondition_result_parameter (tree); -extern tree get_precondition_function (tree); -extern tree get_postcondition_function (tree); -extern tree get_contracts_original_fn (tree); - -extern void emit_assertion (tree); -extern void emit_preconditions (tree); -extern void emit_postconditions_cleanup (tree); -extern void maybe_update_postconditions (tree); -extern void start_function_contracts (tree); -extern void finish_function_contracts (tree); -extern tree apply_postcondition_to_return (tree); -extern void duplicate_contracts (tree, tree); - -inline void -set_decl_contracts (tree decl, tree contract_attrs) -{ - remove_contract_attributes (decl); - DECL_ATTRIBUTES (decl) = chainon (DECL_ATTRIBUTES (decl), contract_attrs); -} - /* RAII sentinel to ensures that deferred access checks are popped before a function returns. */ @@ -8765,6 +8648,29 @@ extern tree coro_get_actor_function (tree); extern tree coro_get_destroy_function (tree); extern tree coro_get_ramp_function (tree); +/* contracts.cc */ +extern tree make_postcondition_variable (cp_expr); +extern tree make_postcondition_variable (cp_expr, tree); +extern tree grok_contract (tree, tree, tree, cp_expr, location_t); +extern tree finish_contract_condition (cp_expr); + +/* Return the first contract in ATTRS, or NULL_TREE if there are none. */ + +inline tree +find_contract (tree attrs) +{ + while (attrs && !cxx_contract_attribute_p (attrs)) + attrs = TREE_CHAIN (attrs); + return attrs; +} + +inline void +set_decl_contracts (tree decl, tree contract_attrs) +{ + remove_contract_attributes (decl); + DECL_ATTRIBUTES (decl) = chainon (DECL_ATTRIBUTES (decl), contract_attrs); +} + /* Inline bodies. */ inline tree diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc index d6eb50a..4a85c85 100644 --- a/gcc/cp/decl.cc +++ b/gcc/cp/decl.cc @@ -12858,9 +12858,10 @@ grokdeclarator (const cp_declarator *declarator, inner_declarator = declarator->declarator; /* Check that contracts aren't misapplied. */ - tree contract_attr = find_contract (declarator->std_attributes); - if (contract_attr && !function_declarator_p (declarator)) - diagnose_misapplied_contracts (contract_attr); + if (tree contract_attr = find_contract (declarator->std_attributes)) + if (declarator->kind != cdk_function + || innermost_code != cdk_function) + diagnose_misapplied_contracts (contract_attr); /* We don't want to warn in parameter context because we don't yet know if the parse will succeed, and this might turn out @@ -13256,8 +13257,7 @@ grokdeclarator (const cp_declarator *declarator, } /* Contract attributes appertain to the declaration. */ - tree *p; - for (p = &attrs; *p;) + for (tree *p = &attrs; *p;) { tree l = *p; if (cxx_contract_attribute_p (l)) diff --git a/gcc/cp/decl2.cc b/gcc/cp/decl2.cc index 6fc6f28..a39bcd1 100644 --- a/gcc/cp/decl2.cc +++ b/gcc/cp/decl2.cc @@ -4423,28 +4423,6 @@ collect_ada_namespace (tree namespc, const char *source_file) collect_ada_namespace (decl, source_file); } -/* cp_tree_defined_p helper -- returns TP if TP is undefined. */ - -static tree -cp_tree_defined_p_r (tree *tp, int *, void *) -{ - enum tree_code code = TREE_CODE (*tp); - if ((code == FUNCTION_DECL || code == VAR_DECL) - && !decl_defined_p (*tp)) - return *tp; - return NULL_TREE; -} - -/* Returns true iff there is a definition for all entities referenced in the - tree TP. */ - -bool -cp_tree_defined_p (tree tp) -{ - tree undefined_t = walk_tree (&tp, cp_tree_defined_p_r, NULL, NULL); - return !undefined_t; -} - /* Returns true iff there is a definition available for variable or function DECL. */ diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index c218dbc..1ceac77 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -10178,7 +10178,7 @@ trees_out::fn_parms_init (tree fn) tree_node (contract); } - /* Write a reference to contracts pre/post functions, if any to avoid + /* Write a reference to contracts pre/post functions, if any, to avoid regenerating them in importers. */ tree_node (DECL_PRE_FN (fn)); tree_node (DECL_POST_FN (fn)); diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index 0f707b5..a0a1988 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -1588,17 +1588,6 @@ cp_ensure_no_oacc_routine (cp_parser *parser) parser->oacc_routine = NULL; } } - -/* True if ATTR is an assertion. */ - -bool -cp_contract_assertion_p (const_tree attr) -{ - /* This is only an assertion if it is a valid cxx contract attribute and the - statement is an ASSERTION_STMT. */ - return cxx_contract_attribute_p (attr) - && TREE_CODE (CONTRACT_STATEMENT (attr)) == ASSERTION_STMT; -} /* Decl-specifiers. */ @@ -1923,32 +1912,23 @@ make_parameter_declarator (cp_decl_specifier_seq *decl_specifiers, return parameter; } -/* Returns a pointer to the function declarator iff DECLARATOR is a - declaration for a function. Returns NULL otherwise. */ +/* Returns true iff DECLARATOR is a declaration for a function. */ -const cp_declarator * -find_innermost_function_declarator (const cp_declarator *declarator) +static bool +function_declarator_p (const cp_declarator *declarator) { while (declarator) { if (declarator->kind == cdk_function && declarator->declarator->kind == cdk_id) - return declarator; + return true; if (declarator->kind == cdk_id || declarator->kind == cdk_decomp || declarator->kind == cdk_error) - return NULL; + return false; declarator = declarator->declarator; } - return NULL; -} - -/* Returns true iff DECLARATOR is a declaration for a function. */ - -bool -function_declarator_p (const cp_declarator *declarator) -{ - return find_innermost_function_declarator (declarator) != NULL; + return false; } /* The parser. */ @@ -31912,8 +31892,6 @@ cp_parser_function_definition_after_declarator (cp_parser* parser, cp_parser_ctor_initializer_opt_and_function_body (parser, /*in_function_try_block=*/false); - fn = current_function_decl; - /* Finish the function. */ fn = finish_function (inline_p); @@ -32919,15 +32897,13 @@ cp_parser_save_default_args (cp_parser* parser, tree decl) if (UNPARSED_NOEXCEPT_SPEC_P (spec)) vec_safe_push (unparsed_noexcepts, decl); - /* If a member function has attributes, they are all deferred. */ + /* Contracts are deferred. */ for (tree attr = DECL_ATTRIBUTES (decl); attr; attr = TREE_CHAIN (attr)) - { - if (cxx_contract_attribute_p (attr)) - { - vec_safe_push (unparsed_contracts, decl); - break; - } - } + if (cxx_contract_attribute_p (attr)) + { + vec_safe_push (unparsed_contracts, decl); + break; + } } /* DEFAULT_ARG contains the saved tokens for the initializer of DECL, diff --git a/gcc/cp/search.cc b/gcc/cp/search.cc index b9931a6..0dbb3be 100644 --- a/gcc/cp/search.cc +++ b/gcc/cp/search.cc @@ -1918,38 +1918,6 @@ maybe_check_overriding_exception_spec (tree overrider, tree basefn) return true; } -/* Replace the any contract attributes on OVERRIDER with a copy where any - references to BASEFN's PARM_DECLs have been rewritten to the corresponding - PARM_DECL in OVERRIDER. */ - -static void -inherit_base_contracts (tree overrider, tree basefn) -{ - tree last = NULL_TREE, contract_attrs = NULL_TREE; - for (tree a = DECL_CONTRACTS (basefn); - a != NULL_TREE; - a = CONTRACT_CHAIN (a)) - { - tree c = copy_node (a); - TREE_VALUE (c) = build_tree_list (TREE_PURPOSE (TREE_VALUE (c)), - copy_node (CONTRACT_STATEMENT (c))); - - tree src = basefn; - tree dst = overrider; - remap_contract (src, dst, CONTRACT_STATEMENT (c), /*duplicate_p=*/true); - - CONTRACT_COMMENT (CONTRACT_STATEMENT (c)) = - copy_node (CONTRACT_COMMENT (CONTRACT_STATEMENT (c))); - - chainon (last, c); - last = c; - if (!contract_attrs) - contract_attrs = c; - } - - set_decl_contracts (overrider, contract_attrs); -} - /* Check that virtual overrider OVERRIDER is acceptable for base function BASEFN. Issue diagnostic, and return zero, if unacceptable. */ diff --git a/gcc/input.cc b/gcc/input.cc index 8baca77..7166c81 100644 --- a/gcc/input.cc +++ b/gcc/input.cc @@ -995,7 +995,7 @@ get_source (location_t start, location_t end) if (line.length () < 1 && (l != expstart.line && l != expend.line)) continue; - /* for the first line in the range, only start at expstart.column */ + /* For the first line in the range, only start at expstart.column */ if (l == expstart.line) { if (expstart.column == 0) @@ -1005,7 +1005,7 @@ get_source (location_t start, location_t end) line = line.subspan (expstart.column - 1, line.length() - expstart.column + 1); } - /* for the last line, don't go past expstart.column */ + /* For the last line, don't go past expend.column */ else if (l == expend.line) { if (line.length () < (size_t)expend.column) @@ -1016,7 +1016,7 @@ get_source (location_t start, location_t end) obstack_grow (&buf_obstack, line.get_buffer (), line.length ()); } - /* Null terminate and finish the buf obstack. */ + /* NUL-terminate and finish the buf obstack. */ obstack_1grow (&buf_obstack, 0); const char *buf = (const char *) obstack_finish (&buf_obstack); |