This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] fix char* restrict
Zack Weinberg <zack@codesourcery.com> writes:
On Wed, Mar 06, 2002 at 12:08:59PM -0800, Dan Nicolaescu wrote:
>
> It seems that restricted char*s don't work.
...
Would you try this patch instead? It's completely untested, but it
attempts to fix the problem in the right place.
zw
===================================================================
Index: c-common.c
--- c-common.c 2002/03/07 11:37:00 1.296
+++ c-common.c 2002/03/09 08:06:37
@@ -2350,7 +2350,8 @@ c_common_get_alias_set (t)
anything. Note that all references need do this. */
if (TREE_CODE_CLASS (TREE_CODE (t)) == 'r'
&& TREE_CODE (TREE_TYPE (t)) == INTEGER_TYPE
- && TYPE_PRECISION (TREE_TYPE (t)) == TYPE_PRECISION (char_type_node))
+ && TYPE_PRECISION (TREE_TYPE (t)) == TYPE_PRECISION (char_type_node)
+ && ! TYPE_RESTRICT (TREE_TYPE (t)))
return 0;
/* That's all the expressions we handle specially. */
This is exactly the first thing I tried when I discovered the
problem. It doesn't work. You need to look a lot harder for
TYPE_RESTRICT. That's probably what all that code in
alias.c:get_alias_set does.
Here's one example of a tree that triggers the code in
c_common_get_alias_set:
<indirect_ref 6a0618
type <integer_type 612280 char QI
size <integer_cst 6720c0 constant 8>
unit size <integer_cst 6720e0 constant 1>
align 8 symtab 0 alias set -1 precision 8 min <integer_cst 672180 -128> max <integer_cst 6721a0 127>
pointer_to_this <pointer_type 676f00>>
arg 0 <plus_expr 6a0600
type <pointer_type 69e680 type <integer_type 612280 char>
unsigned restrict SI
size <integer_cst 672880 constant 32>
unit size <integer_cst 6728e0 constant 4>
align 32 symtab 0 alias set -1>
arg 0 <parm_decl 69e700 a type <pointer_type 69e680 restrict>
unsigned used SI file /tmp/res.c line 2 size <integer_cst 672880 32> unit size <integer_cst 6728e0 4>
align 32 alias set -2 context <function_decl 69e900 g> result <pointer_type 69e680 restrict> initial <pointer_type 69e680 restrict>
(reg/v/f:SI 107) arg-type <pointer_type 69e680 restrict> arg-type-as-written <pointer_type 69e680 restrict>
incoming-rtl (reg:SI 24 %i0) chain <parm_decl 69e780 b>>
arg 1 <convert_expr 6a05e8 type <pointer_type 69e680 restrict>
arg 0 <non_lvalue_expr 6a05d0 type <integer_type 612480 unsigned int>
arg 0 <nop_expr 6a05b8 type <integer_type 612480 unsigned int>
arg 0 <var_decl 69ea00 i>>>>>>
(you need to apply this unreviewed patch:
http://gcc.gnu.org/ml/gcc-patches/2002-02/msg01136.html
to see have "restrict" printed)