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
parent 3d25c396
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> 2010-06-11 Uros Bizjak <ubizjak@gmail.com>
* config/i386/i386.md (pro_epilogue_adjust_stack_1) <TYPE_ALU>: Assert * config/i386/i386.md (pro_epilogue_adjust_stack_1) <TYPE_ALU>: Assert
......
...@@ -4413,12 +4413,13 @@ build_compound_expr (location_t loc, tree expr1, tree expr2) ...@@ -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 /* Issue -Wcast-qual warnings when appropriate. TYPE is the type to
which we are casting. OTYPE is the type of the expression being which we are casting. OTYPE is the type of the expression being
cast. Both TYPE and OTYPE are pointer types. -Wcast-qual appeared cast. Both TYPE and OTYPE are pointer types. LOC is the location
on the command line. Named address space qualifiers are not handled of the cast. -Wcast-qual appeared on the command line. Named
here, because they result in different warnings. */ address space qualifiers are not handled here, because they result
in different warnings. */
static void 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_type = type;
tree in_otype = otype; tree in_otype = otype;
...@@ -4451,15 +4452,15 @@ handle_warn_cast_qual (tree type, tree otype) ...@@ -4451,15 +4452,15 @@ handle_warn_cast_qual (tree type, tree otype)
&& TREE_CODE (in_otype) == POINTER_TYPE); && TREE_CODE (in_otype) == POINTER_TYPE);
if (added) if (added)
warning (OPT_Wcast_qual, "cast adds %q#v qualifier to function type", warning_at (loc, OPT_Wcast_qual,
added); "cast adds %q#v qualifier to function type", added);
if (discarded) if (discarded)
/* There are qualifiers present in IN_OTYPE that are not present /* There are qualifiers present in IN_OTYPE that are not present
in IN_TYPE. */ in IN_TYPE. */
warning (OPT_Wcast_qual, warning_at (loc, OPT_Wcast_qual,
"cast discards %q#v qualifier from pointer target type", "cast discards %q#v qualifier from pointer target type",
discarded); discarded);
if (added || discarded) if (added || discarded)
return; return;
...@@ -4492,10 +4493,10 @@ handle_warn_cast_qual (tree type, tree otype) ...@@ -4492,10 +4493,10 @@ handle_warn_cast_qual (tree type, tree otype)
if ((TYPE_QUALS (in_type) &~ TYPE_QUALS (in_otype)) != 0 if ((TYPE_QUALS (in_type) &~ TYPE_QUALS (in_otype)) != 0
&& !is_const) && !is_const)
{ {
int added = TYPE_QUALS (in_type) &~ TYPE_QUALS (in_otype); warning_at (loc, OPT_Wcast_qual,
warning (OPT_Wcast_qual, "to be safe all intermediate pointers in cast from "
("new %qv qualifier in middle of multi-level non-const cast " "%qT to %qT must be %<const%> qualified",
"is unsafe"), added); otype, type);
break; break;
} }
if (is_const) if (is_const)
...@@ -4599,7 +4600,7 @@ build_c_cast (location_t loc, tree type, tree expr) ...@@ -4599,7 +4600,7 @@ build_c_cast (location_t loc, tree type, tree expr)
if (warn_cast_qual if (warn_cast_qual
&& TREE_CODE (type) == POINTER_TYPE && TREE_CODE (type) == POINTER_TYPE
&& TREE_CODE (otype) == 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 /* Warn about conversions between pointers to disjoint
address spaces. */ address spaces. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment