aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManuel López-Ibáñez <manu@gcc.gnu.org>2010-06-11 09:43:53 +0000
committerManuel López-Ibáñez <manu@gcc.gnu.org>2010-06-11 09:43:53 +0000
commit2ee3cb3591bfa67a216efe877ddcfca65851bbc8 (patch)
tree5ccc3ce7c2754aaa5c4cd82a8c1dd624e4991b07
parent3d25c3960ba2eec2cfc8498c73c939619ec0efc9 (diff)
downloadgcc-2ee3cb3591bfa67a216efe877ddcfca65851bbc8.zip
gcc-2ee3cb3591bfa67a216efe877ddcfca65851bbc8.tar.gz
gcc-2ee3cb3591bfa67a216efe877ddcfca65851bbc8.tar.bz2
c-typeck.c (handle_warn_cast_qual): Add loc parameter.
2010-06-11 Manuel López-Ibáñez <manu@gcc.gnu.org> * c-typeck.c (handle_warn_cast_qual): Add loc parameter. Improve warning message. (build_c_cast): Pass location to handle_warn_cast_qual. From-SVN: r160601
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/c-typeck.c29
2 files changed, 21 insertions, 14 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 561b0ee..742950c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2010-06-11 Manuel López-Ibáñez <manu@gcc.gnu.org>
+
+ * c-typeck.c (handle_warn_cast_qual): Add loc
+ parameter. Improve warning message.
+ (build_c_cast): Pass location to handle_warn_cast_qual.
+
2010-06-11 Uros Bizjak <ubizjak@gmail.com>
* config/i386/i386.md (pro_epilogue_adjust_stack_1) <TYPE_ALU>: Assert
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index b2d3986..f8bfb51 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -4413,12 +4413,13 @@ build_compound_expr (location_t loc, tree expr1, tree expr2)
/* Issue -Wcast-qual warnings when appropriate. TYPE is the type to
which we are casting. OTYPE is the type of the expression being
- cast. Both TYPE and OTYPE are pointer types. -Wcast-qual appeared
- on the command line. Named address space qualifiers are not handled
- here, because they result in different warnings. */
+ cast. Both TYPE and OTYPE are pointer types. LOC is the location
+ of the cast. -Wcast-qual appeared on the command line. Named
+ address space qualifiers are not handled here, because they result
+ in different warnings. */
static void
-handle_warn_cast_qual (tree type, tree otype)
+handle_warn_cast_qual (location_t loc, tree type, tree otype)
{
tree in_type = type;
tree in_otype = otype;
@@ -4451,15 +4452,15 @@ handle_warn_cast_qual (tree type, tree otype)
&& TREE_CODE (in_otype) == POINTER_TYPE);
if (added)
- warning (OPT_Wcast_qual, "cast adds %q#v qualifier to function type",
- added);
+ warning_at (loc, OPT_Wcast_qual,
+ "cast adds %q#v qualifier to function type", added);
if (discarded)
/* There are qualifiers present in IN_OTYPE that are not present
in IN_TYPE. */
- warning (OPT_Wcast_qual,
- "cast discards %q#v qualifier from pointer target type",
- discarded);
+ warning_at (loc, OPT_Wcast_qual,
+ "cast discards %q#v qualifier from pointer target type",
+ discarded);
if (added || discarded)
return;
@@ -4492,10 +4493,10 @@ handle_warn_cast_qual (tree type, tree otype)
if ((TYPE_QUALS (in_type) &~ TYPE_QUALS (in_otype)) != 0
&& !is_const)
{
- int added = TYPE_QUALS (in_type) &~ TYPE_QUALS (in_otype);
- warning (OPT_Wcast_qual,
- ("new %qv qualifier in middle of multi-level non-const cast "
- "is unsafe"), added);
+ warning_at (loc, OPT_Wcast_qual,
+ "to be safe all intermediate pointers in cast from "
+ "%qT to %qT must be %<const%> qualified",
+ otype, type);
break;
}
if (is_const)
@@ -4599,7 +4600,7 @@ build_c_cast (location_t loc, tree type, tree expr)
if (warn_cast_qual
&& TREE_CODE (type) == POINTER_TYPE
&& TREE_CODE (otype) == POINTER_TYPE)
- handle_warn_cast_qual (type, otype);
+ handle_warn_cast_qual (loc, type, otype);
/* Warn about conversions between pointers to disjoint
address spaces. */