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] better error reporting and remove some code


After my last patch with the type qualifier stuff ran into this other
code here. I'm almost positive that it's not possible to trigger the old
error messages with comptypes taking place beforehand. I tried to
construct some different testcases to trigger it, but failed unless I
pulled the comptypes check out :)

So, I made the error message a bit cleaner, annotated the check in
comptypes with the location in the standard and fixed the testcase that
triggers it in mainline.

OK?

-eric

-- 
Eric Christopher <echristo@redhat.com>

2004-06-13  Eric Christopher  <echristo@redhat.com>

	* c-decl.c (diagnose_mismatched_decls): Improve error message.
	Remove unused code.
	* c-typeck.c (comptypes): Add location in standard we're
	checking.

2004-06-13  Eric Christopher  <echristo@redhat.com>

	* gcc.dg/noncompile/redecl-1.c: Fix error message.

Index: gcc/c-decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.506
diff -u -p -w -r1.506 c-decl.c
--- gcc/c-decl.c	7 Jun 2004 19:06:28 -0000	1.506
+++ gcc/c-decl.c	13 Jun 2004 15:44:51 -0000
@@ -1138,6 +1138,9 @@ diagnose_mismatched_decls (tree newdecl,
 	}
       else
 	{
+	  if (TYPE_QUALS (newtype) != TYPE_QUALS (oldtype))
+	    error ("%J conflicting type qualifiers for '%D'", newdecl,
newdecl);
+	  else
 	  error ("%Jconflicting types for '%D'", newdecl, newdecl);
 	  diagnose_arglist_conflict (newdecl, olddecl, newtype, oldtype);
 	  locate_old_decl (olddecl, error);
@@ -1365,28 +1368,6 @@ diagnose_mismatched_decls (tree newdecl,
 	  locate_old_decl (olddecl, error);
 	  return false;
 	}
-
-      /* These bits are only type qualifiers when applied to objects. 
*/
-      if (TREE_THIS_VOLATILE (newdecl) != TREE_THIS_VOLATILE (olddecl))
-	{
-	  if (TREE_THIS_VOLATILE (newdecl))
-	    pedwarn ("%Jvolatile declaration of '%D' follows "
-		     "non-volatile declaration", newdecl, newdecl);
-	  else
-	    pedwarn ("%Jnon-volatile declaration of '%D' follows "
-		     "volatile declaration", newdecl, newdecl);
-	  pedwarned = true;
-	}
-      if (TREE_READONLY (newdecl) != TREE_READONLY (olddecl))
-	{
-	  if (TREE_READONLY (newdecl))
-	    pedwarn ("%Jconst declaration of '%D' follows "
-		     "non-const declaration", newdecl, newdecl);
-	  else
-	    pedwarn ("%Jnon-const declaration of '%D' follows "
-		     "const declaration", newdecl, newdecl);
-	  pedwarned = true;
-	}
     }
 
   /* Optional warning for completely redundant decls.  */
Index: gcc/c-typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-typeck.c,v
retrieving revision 1.312
diff -u -p -w -r1.312 c-typeck.c
--- gcc/c-typeck.c	12 Jun 2004 06:02:51 -0000	1.312
+++ gcc/c-typeck.c	13 Jun 2004 15:44:53 -0000
@@ -598,7 +598,7 @@ comptypes (tree type1, tree type2, int f
   if (TREE_CODE (t1) != TREE_CODE (t2))
     return 0;
 
-  /* Qualifiers must match.  */
+  /* Qualifiers must match. C99 6.7.3p9 */
 
   if (TYPE_QUALS (t1) != TYPE_QUALS (t2))
     return 0;
Index: gcc/testsuite/gcc.dg/noncompile/redecl-1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/noncompile/redecl-1.c,v
retrieving revision 1.3
diff -u -p -w -r1.3 redecl-1.c
--- gcc/testsuite/gcc.dg/noncompile/redecl-1.c	8 Jun 2001 22:33:46
-0000	1.3
+++ gcc/testsuite/gcc.dg/noncompile/redecl-1.c	13 Jun 2004 15:44:53
-0000
@@ -5,6 +5,5 @@ int
 foo ()
 {
   int bar; /* { dg-error "previous.*decl" "previous.*decl" } */
-  volatile int bar; /* { dg-error "conflicting types" "conflicting
types" } */
+  volatile int bar; /* { dg-error "conflicting type qualifiers"
"conflicting type qualifiers" } */
 }
-



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