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]

[named-addr-spaces-branch][Patch,committed] Clean up message for conficting address spaces


[gcc]
2008-11-25  Michael Meissner  <meissner@linux.vnet.ibm.com>

	* c-decl.c (diagnose_mismatched_decls): Report on mis-matched
	named address spaces.
	(grokdeclarator): Clear named address from qualifiers before
	checking on whether to warn about ISO C forbidding qualified
	function types.

	* config/spu/spu.c (spu_addr_space_name): Return "generic" for the
	generic address space.

[gcc/testsuite]
2008-11-25  Michael Meissner  <meissner@linux.vnet.ibm.com>

	* gcc.target/spu/ea/errors.c (ea_var): Check for conflicting named
	address spaces.

Index: gcc/testsuite/gcc.target/spu/ea/errors.c
===================================================================
--- gcc/testsuite/gcc.target/spu/ea/errors.c	(revision 142168)
+++ gcc/testsuite/gcc.target/spu/ea/errors.c	(working copy)
@@ -36,3 +36,6 @@ int func4 (int *__ea x)	    /* { dg-erro
   struct A i = (__ea struct A) { 1 };	/* { dg-error "compound literal qualified by address-space qualifier" } */
   return i.a;
 }
+
+extern __ea int ea_var;		/* { dg-message "note: previous.*decl" "previous.*decl" } */
+int ea_var;			/* { dg-error "conflicting named address spaces" "conflicting named address spaces" } */
Index: gcc/c-decl.c
===================================================================
--- gcc/c-decl.c	(revision 142168)
+++ gcc/c-decl.c	(working copy)
@@ -1246,8 +1246,23 @@ diagnose_mismatched_decls (tree newdecl,
 	}
       else
 	{
-	  if (TYPE_QUALS (newtype) != TYPE_QUALS (oldtype))
-	    error ("conflicting type qualifiers for %q+D", newdecl);
+	  int new_quals = TYPE_QUALS (newtype);
+	  int old_quals = TYPE_QUALS (oldtype);
+
+	  if (new_quals != old_quals)
+	    {
+	      addr_space_t new_addr = DECODE_QUAL_ADDR_SPACE (new_quals);
+	      addr_space_t old_addr = DECODE_QUAL_ADDR_SPACE (old_quals);
+	      if (new_addr != old_addr)
+		error ("conflicting named address spaces (%s vs %s) for %q+D",
+		       targetm.addr_space.name (new_addr),
+		       targetm.addr_space.name (old_addr),
+		       newdecl);
+
+	      if (CLEAR_QUAL_ADDR_SPACE (new_quals)
+		  != CLEAR_QUAL_ADDR_SPACE (old_quals))
+		error ("conflicting type qualifiers for %q+D", newdecl);
+	    }
 	  else
 	    error ("conflicting types for %q+D", newdecl);
 	  diagnose_arglist_conflict (newdecl, olddecl, newtype, oldtype);
@@ -4605,7 +4620,7 @@ grokdeclarator (const struct c_declarato
 	       for the pointer.  */
 
 	    if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
-		&& type_quals)
+		&& CLEAR_QUAL_ADDR_SPACE (type_quals))
 	      pedwarn (input_location, OPT_pedantic,
 		       "ISO C forbids qualified function types");
 	    if (type_quals)
@@ -4818,7 +4833,7 @@ grokdeclarator (const struct c_declarato
 	  }
 	else if (TREE_CODE (type) == FUNCTION_TYPE)
 	  {
-	    if (type_quals)
+	    if (CLEAR_QUAL_ADDR_SPACE (type_quals))
 	      pedwarn (input_location, OPT_pedantic,
 		       "ISO C forbids qualified function types");
 	    if (type_quals)
@@ -4907,7 +4922,8 @@ grokdeclarator (const struct c_declarato
 	DECL_SOURCE_LOCATION (decl) = declarator->id_loc;
 	decl = build_decl_attribute_variant (decl, decl_attr);
 
-	if (pedantic && type_quals && !DECL_IN_SYSTEM_HEADER (decl))
+	if (pedantic && CLEAR_QUAL_ADDR_SPACE (type_quals)
+	    && !DECL_IN_SYSTEM_HEADER (decl))
 	  pedwarn (input_location, OPT_pedantic,
 		   "ISO C forbids qualified function types");
 
Index: gcc/config/spu/spu.c
===================================================================
--- gcc/config/spu/spu.c	(revision 142168)
+++ gcc/config/spu/spu.c	(working copy)
@@ -6609,7 +6609,7 @@ spu_addr_space_name (addr_space_t addrsp
   switch (addrspace)
     {
     case ADDR_SPACE_GENERIC:
-      return "";
+      return "generic";
 
     case ADDR_SPACE_EA:
       return "__ea";

-- 
Michael Meissner, IBM
4 Technology Place Drive, MS 2203A, Westford, MA, 01886, USA
meissner@linux.vnet.ibm.com


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