aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNathan Froyd <froydnj@codesourcery.com>2010-12-09 21:50:23 +0000
committerNathan Froyd <froydnj@gcc.gnu.org>2010-12-09 21:50:23 +0000
commit7a6daeb0d68cba3ace6ceb2d8113bc0ee7ca7c18 (patch)
treedf909e57688b1155ec89d442b57ba0b2026135a9 /gcc
parent083586b88030b716c436119d18547063ed802cc5 (diff)
downloadgcc-7a6daeb0d68cba3ace6ceb2d8113bc0ee7ca7c18.zip
gcc-7a6daeb0d68cba3ace6ceb2d8113bc0ee7ca7c18.tar.gz
gcc-7a6daeb0d68cba3ace6ceb2d8113bc0ee7ca7c18.tar.bz2
c-typeck.c (build_indirect_ref): Call invalid_indirection_error.
gcc/ * c-typeck.c (build_indirect_ref): Call invalid_indirection_error. gcc/c-family/ * c-common.h (invalid_indirection_error): Declare. * c-common.c (invalid_indirection_error): Define. gcc/cp/ * typeck.c (cp_build_indirect_ref): Call invalid_indirection_error. From-SVN: r167666
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog4
-rw-r--r--gcc/c-family/ChangeLog5
-rw-r--r--gcc/c-family/c-common.c37
-rw-r--r--gcc/c-family/c-common.h1
-rw-r--r--gcc/c-typeck.c22
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/typeck.c19
7 files changed, 55 insertions, 37 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 9ba828f..d9d2724 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,7 @@
+2010-12-09 Nathan Froyd <froydnj@codesourcery.com>
+
+ * c-typeck.c (build_indirect_ref): Call invalid_indirection_error.
+
2010-12-09 Joseph Myers <joseph@codesourcery.com>
* doc/extend.texi (Attribute Syntax): Correct description of
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 2ea3960..495816b 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,8 @@
+2010-12-09 Nathan Froyd <froydnj@codesourcery.com>
+
+ * c-common.h (invalid_indirection_error): Declare.
+ * c-common.c (invalid_indirection_error): Define.
+
2010-12-03 Richard Guenther <rguenther@suse.de>
PR c/46745
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 7a57838..8d0fcc3 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -8585,6 +8585,43 @@ lvalue_error (enum lvalue_use use)
gcc_unreachable ();
}
}
+
+/* Print an error message for an invalid indirection of type TYPE.
+ ERRSTRING is the name of the operator for the indirection. */
+
+void
+invalid_indirection_error (location_t loc, tree type, ref_operator errstring)
+{
+ switch (errstring)
+ {
+ case RO_NULL:
+ gcc_assert (c_dialect_cxx ());
+ error_at (loc, "invalid type argument (have %qT)", type);
+ break;
+ case RO_ARRAY_INDEXING:
+ error_at (loc,
+ "invalid type argument of array indexing (have %qT)",
+ type);
+ break;
+ case RO_UNARY_STAR:
+ error_at (loc,
+ "invalid type argument of unary %<*%> (have %qT)",
+ type);
+ break;
+ case RO_ARROW:
+ error_at (loc,
+ "invalid type argument of %<->%> (have %qT)",
+ type);
+ break;
+ case RO_IMPLICIT_CONVERSION:
+ error_at (loc,
+ "invalid type argument of implicit conversion (have %qT)",
+ type);
+ break;
+ default:
+ gcc_unreachable ();
+ }
+}
/* *PTYPE is an incomplete array. Complete it with a domain based on
INITIAL_VALUE. If INITIAL_VALUE is not present, use 1 if DO_DEFAULT
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index 928e502..b6f8d39 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -929,6 +929,7 @@ enum lvalue_use {
};
extern void lvalue_error (enum lvalue_use);
+extern void invalid_indirection_error (location_t, tree, ref_operator);
extern int complete_array_type (tree *, tree, bool);
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index 7bba44e..cbe9f20 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -2267,26 +2267,8 @@ build_indirect_ref (location_t loc, tree ptr, ref_operator errstring)
}
}
else if (TREE_CODE (pointer) != ERROR_MARK)
- switch (errstring)
- {
- case RO_ARRAY_INDEXING:
- error_at (loc,
- "invalid type argument of array indexing (have %qT)",
- type);
- break;
- case RO_UNARY_STAR:
- error_at (loc,
- "invalid type argument of unary %<*%> (have %qT)",
- type);
- break;
- case RO_ARROW:
- error_at (loc,
- "invalid type argument of %<->%> (have %qT)",
- type);
- break;
- default:
- gcc_unreachable ();
- }
+ invalid_indirection_error (loc, type, errstring);
+
return error_mark_node;
}
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 3c14d73..ae7d057 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
2010-12-09 Nathan Froyd <froydnj@codesourcery.com>
+ * typeck.c (cp_build_indirect_ref): Call invalid_indirection_error.
+
+2010-12-09 Nathan Froyd <froydnj@codesourcery.com>
+
* typeck.c (composite_pointer_error): New function.
(composite_pointer_type_r, composite_pointer_type): Call it.
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index a4bbd4e..f055bbc 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -2776,23 +2776,8 @@ cp_build_indirect_ref (tree ptr, ref_operator errorstring,
gcc_unreachable ();
}
else if (pointer != error_mark_node)
- switch (errorstring)
- {
- case RO_NULL:
- error ("invalid type argument");
- break;
- case RO_ARRAY_INDEXING:
- error ("invalid type argument of array indexing");
- break;
- case RO_UNARY_STAR:
- error ("invalid type argument of unary %<*%>");
- break;
- case RO_IMPLICIT_CONVERSION:
- error ("invalid type argument of implicit conversion");
- break;
- default:
- gcc_unreachable ();
- }
+ invalid_indirection_error (input_location, type, errorstring);
+
return error_mark_node;
}