Bug 36906 - #pragma GNU poison index()
Summary: #pragma GNU poison index()
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: preprocessor (show other bugs)
Version: unknown
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-23 06:50 UTC by Dave Yost
Modified: 2008-12-24 23:07 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dave Yost 2008-07-23 06:50:54 UTC
There should be a way to poison a symbol only when it is used as a function or macro call. I suggest that following a symbol with a pair of parentheses might be a serviceable syntax for this. With this feature, the symbol rindex would still be usable for variables.
Comment 1 pinskia@gmail.com 2008-07-23 07:09:20 UTC
Subject: Re:   New: #pragma GNU poison index()

Try the attribute deprecated.

Sent from my iPhone

On Jul 22, 2008, at 23:50, "Dave at Yost dot com" <gcc-bugzilla@gcc.gnu.org 
 > wrote:

> There should be a way to poison a symbol only when it is used as a  
> function or
> macro call. I suggest that following a symbol with a pair of  
> parentheses might
> be a serviceable syntax for this. With this feature, the symbol  
> rindex would
> still be usable for variables.
>
>
> -- 
>           Summary: #pragma GNU poison index()
>           Product: gcc
>           Version: unknown
>            Status: UNCONFIRMED
>          Severity: enhancement
>          Priority: P3
>         Component: preprocessor
>        AssignedTo: unassigned at gcc dot gnu dot org
>        ReportedBy: Dave at Yost dot com
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36906
>
Comment 2 Andrew Pinski 2008-08-11 00:28:22 UTC
Let me expand on what I mean by the attribute deprecated.
See http://gcc.gnu.org/onlinedocs/gcc-4.3.0/gcc/Function-Attributes.html:

deprecated
The deprecated attribute results in a warning if the function is used anywhere in the source file. This is useful when identifying functions that are expected to be removed in a future version of a program. The warning also includes the location of the declaration of the deprecated function, to enable users to easily find further information about why the function is deprecated, or what they should do instead. Note that the warnings only occurs for uses:
          int old_fn () __attribute__ ((deprecated));
          int old_fn ();
          int (*fn_ptr)() = old_fn;
     
results in a warning on line 3 but not line 2.

The deprecated attribute can also be used for variables and types (see Variable Attributes, see Type Attributes.) 
Comment 3 Tom Tromey 2008-09-02 19:22:34 UTC
One problem with this approach is that this code would not error:

#include <string.h>
char (*fnptr)() = rindex;

I tend to agree with Andrew -- poisoning is too crude a tool for this use.

Is there a reason you do not use deprecation here?
Comment 4 Andrew Pinski 2008-12-24 23:07:27 UTC
No answer in 3 months so closing.