This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix types and bogus warning for C frontend


This fixes the types of the INDIRECT_REF the C frontend
generates to match exactly.

Bootstrapped and tested on x86_64-linux-gnu as part of
http://gcc.gnu.org/ml/gcc-patches/2005-06/msg00151.html

Ok for mainline?

Thanks,
Richard.



2005-06-02  Richard Guenther  <rguenth@gcc.gnu.org>

	* c-typeck.c (build_indirect_ref): Build INDIRECT_REF
	with correct type.

	* gcc.dg/wtypequal.c: New testcase.

Index: c-typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-typeck.c,v
retrieving revision 1.446
diff -c -3 -p -r1.446 c-typeck.c
*** c-typeck.c	25 May 2005 03:58:56 -0000	1.446
--- c-typeck.c	2 Jun 2005 09:38:39 -0000
*************** build_indirect_ref (tree ptr, const char
*** 1638,1649 ****
        else
  	{
  	  tree t = TREE_TYPE (type);
- 	  tree mvt = t;
  	  tree ref;
  
! 	  if (TREE_CODE (mvt) != ARRAY_TYPE)
! 	    mvt = TYPE_MAIN_VARIANT (mvt);
! 	  ref = build1 (INDIRECT_REF, mvt, pointer);
  
  	  if (!COMPLETE_OR_VOID_TYPE_P (t) && TREE_CODE (t) != ARRAY_TYPE)
  	    {
--- 1638,1646 ----
        else
  	{
  	  tree t = TREE_TYPE (type);
  	  tree ref;
  
! 	  ref = build1 (INDIRECT_REF, t, pointer);
  
  	  if (!COMPLETE_OR_VOID_TYPE_P (t) && TREE_CODE (t) != ARRAY_TYPE)
  	    {


/* { dg-do compile } */

int *__restrict *p;
void f(void)
{
  __typeof(*p) *q = p; /* { dg-bogus "discards qualifiers" } */
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]