From: Marc Glisse <marc.glisse@inria.fr>
To: Tom Tromey <tromey@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: extern "C" fixes for sunCC
Date: Thu, 03 Jan 2013 16:12:00 -0000 [thread overview]
Message-ID: <alpine.DEB.2.02.1301031651190.3722@laptop-mg.saclay.inria.fr> (raw)
In-Reply-To: <87lica6zkz.fsf@fleche.redhat.com>
[-- Attachment #1: Type: TEXT/PLAIN, Size: 1110 bytes --]
On Thu, 3 Jan 2013, Tom Tromey wrote:
>>>>>> "Marc" == Marc Glisse <marc.glisse@inria.fr> writes:
>
> Marc> libcpp/
> Marc> * line-map.c (get_combined_adhoc_loc): Cast to extern "C" type.
>
> Yucky.
Yes, there is a discussion of what is necessary for a real fix (and an
alternate hack) in the PR:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50177
Do you prefer an other approach?
> Marc> line_map_realloc reallocator
> Marc> - = set->reallocator ? set->reallocator : xrealloc;
> Marc> + = set->reallocator ? set->reallocator
> Marc> + : (line_map_realloc) xrealloc;
>
> The indentation is wrong here, and it needs extra parens, per the GNU
> coding standards.
>
> I think it should have a comment as well.
Like this? (I'll test if approved, but I am not sure what was wrong with
the indentation and parentheses so it may be wrong again)
Reformatting the patch, I noticed that I only fixed one of the 3
occurences, so here are all 3.
* line-map.c (get_combined_adhoc_loc): Cast from extern "C" type.
(new_linemap): Likewise.
(linemap_enter_macro): Likewise.
--
Marc Glisse
[-- Attachment #2: Type: TEXT/PLAIN, Size: 3542 bytes --]
Index: line-map.c
===================================================================
--- line-map.c (revision 194796)
+++ line-map.c (working copy)
@@ -115,22 +115,24 @@ get_combined_adhoc_loc (struct line_maps
lb.data = data;
slot = (struct location_adhoc_data **)
htab_find_slot (set->location_adhoc_data_map.htab, &lb, INSERT);
if (*slot == NULL)
{
if (set->location_adhoc_data_map.curr_loc >=
set->location_adhoc_data_map.allocated)
{
char *orig_data = (char *) set->location_adhoc_data_map.data;
long long offset;
- line_map_realloc reallocator
- = set->reallocator ? set->reallocator : xrealloc;
+ /* Cast away extern "C" from the type of xrealloc. */
+ line_map_realloc reallocator = set->reallocator
+ ? set->reallocator
+ : ((line_map_realloc) xrealloc);
if (set->location_adhoc_data_map.allocated == 0)
set->location_adhoc_data_map.allocated = 128;
else
set->location_adhoc_data_map.allocated *= 2;
set->location_adhoc_data_map.data = (struct location_adhoc_data *)
reallocator (set->location_adhoc_data_map.data,
set->location_adhoc_data_map.allocated
* sizeof (struct location_adhoc_data));
offset = (char *) (set->location_adhoc_data_map.data) - orig_data;
@@ -210,22 +212,24 @@ new_linemap (struct line_maps *set,
/* Depending on this variable, a macro map would be allocated in a
different memory location than an ordinary map. */
bool macro_map_p = (reason == LC_ENTER_MACRO);
struct line_map *result;
if (LINEMAPS_USED (set, macro_map_p) == LINEMAPS_ALLOCATED (set, macro_map_p))
{
/* We ran out of allocated line maps. Let's allocate more. */
unsigned alloc_size;
- line_map_realloc reallocator
- = set->reallocator ? set->reallocator : xrealloc;
+ /* Cast away extern "C" from the type of xrealloc. */
+ line_map_realloc reallocator = set->reallocator
+ ? set->reallocator
+ : ((line_map_realloc) xrealloc);
line_map_round_alloc_size_func round_alloc_size =
set->round_alloc_size;
/* We are going to execute some dance to try to reduce the
overhead of the memory allocator, in case we are using the
ggc-page.c one.
The actual size of memory we are going to get back from the
allocator is the smallest power of 2 that is greater than the
size we requested. So let's consider that size then. */
@@ -423,22 +427,24 @@ linemap_tracks_macro_expansion_locs_p (s
locations, this function returns NULL. In that case, callers of
this function cannot encode {line,column} pairs into locations of
macro tokens anymore. */
const struct line_map *
linemap_enter_macro (struct line_maps *set, struct cpp_hashnode *macro_node,
source_location expansion, unsigned int num_tokens)
{
struct line_map *map;
source_location start_location;
- line_map_realloc reallocator
- = set->reallocator ? set->reallocator : xrealloc;
+ /* Cast away extern "C" from the type of xrealloc. */
+ line_map_realloc reallocator = set->reallocator
+ ? set->reallocator
+ : ((line_map_realloc) xrealloc);
start_location = LINEMAPS_MACRO_LOWEST_LOCATION (set) - num_tokens;
if (start_location <= set->highest_line
|| start_location > LINEMAPS_MACRO_LOWEST_LOCATION (set))
/* We ran out of macro map space. */
return NULL;
map = new_linemap (set, LC_ENTER_MACRO);
next prev parent reply other threads:[~2013-01-03 16:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-11 21:40 Marc Glisse
2013-01-02 13:45 ` Marc Glisse
2013-01-02 14:09 ` Richard Biener
2013-01-03 15:44 ` Tom Tromey
2013-01-03 16:12 ` Marc Glisse [this message]
2013-01-03 17:28 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.2.02.1301031651190.3722@laptop-mg.saclay.inria.fr \
--to=marc.glisse@inria.fr \
--cc=gcc-patches@gcc.gnu.org \
--cc=tromey@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).