aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Froyd <froydnj@codesourcery.com>2010-12-09 21:47:12 +0000
committerNathan Froyd <froydnj@gcc.gnu.org>2010-12-09 21:47:12 +0000
commit083586b88030b716c436119d18547063ed802cc5 (patch)
tree1fc9126d61bf7e336d3a06ffdd0ebeb7df40ea6f
parent197ef306047f8d5c3cb25540f4207a13bc559e28 (diff)
downloadgcc-083586b88030b716c436119d18547063ed802cc5.zip
gcc-083586b88030b716c436119d18547063ed802cc5.tar.gz
gcc-083586b88030b716c436119d18547063ed802cc5.tar.bz2
typeck.c (composite_pointer_error): New function.
* typeck.c (composite_pointer_error): New function. (composite_pointer_type_r, composite_pointer_type): Call it. From-SVN: r167665
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/typeck.c94
2 files changed, 38 insertions, 61 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index fb14862..3c14d73 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2010-12-09 Nathan Froyd <froydnj@codesourcery.com>
+
+ * typeck.c (composite_pointer_error): New function.
+ (composite_pointer_type_r, composite_pointer_type): Call it.
+
2010-12-08 Jason Merrill <jason@redhat.com>
PR c++/46348
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 7416f09..a4bbd4e 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -443,6 +443,35 @@ type_after_usual_arithmetic_conversions (tree t1, tree t2)
return cp_common_type (t1, t2);
}
+static void
+composite_pointer_error (diagnostic_t kind, tree t1, tree t2,
+ composite_pointer_operation operation)
+{
+ switch (operation)
+ {
+ case CPO_COMPARISON:
+ emit_diagnostic (kind, input_location, 0,
+ "comparison between "
+ "distinct pointer types %qT and %qT lacks a cast",
+ t1, t2);
+ break;
+ case CPO_CONVERSION:
+ emit_diagnostic (kind, input_location, 0,
+ "conversion between "
+ "distinct pointer types %qT and %qT lacks a cast",
+ t1, t2);
+ break;
+ case CPO_CONDITIONAL_EXPR:
+ emit_diagnostic (kind, input_location, 0,
+ "conditional expression between "
+ "distinct pointer types %qT and %qT lacks a cast",
+ t1, t2);
+ break;
+ default:
+ gcc_unreachable ();
+ }
+}
+
/* Subroutine of composite_pointer_type to implement the recursive
case. See that function for documentation of the parameters. */
@@ -486,28 +515,8 @@ composite_pointer_type_r (tree t1, tree t2,
else
{
if (complain & tf_error)
- {
- switch (operation)
- {
- case CPO_COMPARISON:
- permerror (input_location, "comparison between "
- "distinct pointer types %qT and %qT lacks a cast",
- t1, t2);
- break;
- case CPO_CONVERSION:
- permerror (input_location, "conversion between "
- "distinct pointer types %qT and %qT lacks a cast",
- t1, t2);
- break;
- case CPO_CONDITIONAL_EXPR:
- permerror (input_location, "conditional expression between "
- "distinct pointer types %qT and %qT lacks a cast",
- t1, t2);
- break;
- default:
- gcc_unreachable ();
- }
- }
+ composite_pointer_error (DK_PERMERROR, t1, t2, operation);
+
result_type = void_type_node;
}
result_type = cp_build_qualified_type (result_type,
@@ -520,28 +529,7 @@ composite_pointer_type_r (tree t1, tree t2,
if (!same_type_p (TYPE_PTRMEM_CLASS_TYPE (t1),
TYPE_PTRMEM_CLASS_TYPE (t2))
&& (complain & tf_error))
- {
- switch (operation)
- {
- case CPO_COMPARISON:
- permerror (input_location, "comparison between "
- "distinct pointer types %qT and %qT lacks a cast",
- t1, t2);
- break;
- case CPO_CONVERSION:
- permerror (input_location, "conversion between "
- "distinct pointer types %qT and %qT lacks a cast",
- t1, t2);
- break;
- case CPO_CONDITIONAL_EXPR:
- permerror (input_location, "conditional expression between "
- "distinct pointer types %qT and %qT lacks a cast",
- t1, t2);
- break;
- default:
- gcc_unreachable ();
- }
- }
+ composite_pointer_error (DK_PERMERROR, t1, t2, operation);
result_type = build_ptrmem_type (TYPE_PTRMEM_CLASS_TYPE (t1),
result_type);
}
@@ -662,23 +650,7 @@ composite_pointer_type (tree t1, tree t2, tree arg1, tree arg2,
else
{
if (complain & tf_error)
- switch (operation)
- {
- case CPO_COMPARISON:
- error ("comparison between distinct "
- "pointer types %qT and %qT lacks a cast", t1, t2);
- break;
- case CPO_CONVERSION:
- error ("conversion between distinct "
- "pointer types %qT and %qT lacks a cast", t1, t2);
- break;
- case CPO_CONDITIONAL_EXPR:
- error ("conditional expression between distinct "
- "pointer types %qT and %qT lacks a cast", t1, t2);
- break;
- default:
- gcc_unreachable ();
- }
+ composite_pointer_error (DK_ERROR, t1, t2, operation);
return error_mark_node;
}
}