aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorNathan Froyd <froydnj@codesourcery.com>2010-12-10 14:20:26 +0000
committerNathan Froyd <froydnj@gcc.gnu.org>2010-12-10 14:20:26 +0000
commit4816c5938dfb6d9510b43f9223dab24af530e00e (patch)
treeba520fa5422c9cc016fb1652664a621506caa191 /gcc/cp
parentfee457233eea9e0f2a88273ba3e6b75b9f9b73d9 (diff)
downloadgcc-4816c5938dfb6d9510b43f9223dab24af530e00e.zip
gcc-4816c5938dfb6d9510b43f9223dab24af530e00e.tar.gz
gcc-4816c5938dfb6d9510b43f9223dab24af530e00e.tar.bz2
c-typeck.c (readonly_error): Delete.
gcc/ * c-typeck.c (readonly_error): Delete. gcc/c-family/ * c-common.h (readonly_error): Declare. * c-common.c (readonly_error): Define. gcc/cp/ * cp-tree.h (readonly_error_kind): Delete. (readonly_error): Rename to... (cxx_readonly_error): ...this. Change second argument to be an enum lvalue_use. * semantics.c (finish_asm_stmt): Call cxx_readonly_error. * typeck.c (cp_build_unary_op): Likewise. (cp_build_modify_expr): Likewise. * typeck2.c (readonly_error): Rename to... (cxx_readonly_error): ...this. Delegate to readonly_error for most cases. gcc/testsuite/ * gcc.dg/dfp/struct-union.c: Adjust. * gcc.dg/lvalue-2.c: Adjust. * gcc.dg/pr21419.c: Adjust. * gcc.dg/qual-component-1.c: Adjust. * g++.dg/other/const1.C: Adjust. From-SVN: r167687
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog13
-rw-r--r--gcc/cp/cp-tree.h15
-rw-r--r--gcc/cp/semantics.c2
-rw-r--r--gcc/cp/typeck.c8
-rw-r--r--gcc/cp/typeck2.c114
5 files changed, 40 insertions, 112 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index a78f82c..de7160f 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,16 @@
+2010-12-10 Nathan Froyd <froydnj@codesourcery.com>
+
+ * cp-tree.h (readonly_error_kind): Delete.
+ (readonly_error): Rename to...
+ (cxx_readonly_error): ...this. Change second argument to be an
+ enum lvalue_use.
+ * semantics.c (finish_asm_stmt): Call cxx_readonly_error.
+ * typeck.c (cp_build_unary_op): Likewise.
+ (cp_build_modify_expr): Likewise.
+ * typeck2.c (readonly_error): Rename to...
+ (cxx_readonly_error): ...this. Delegate to readonly_error for
+ most cases.
+
2010-12-10 Nicola Pero <nicola.pero@meta-innovation.com>
* parser.c (cp_parser_objc_superclass_or_category): Recognize
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 03c02fc..79f9f24 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -406,19 +406,6 @@ typedef enum composite_pointer_operation
CPO_CONDITIONAL_EXPR
} composite_pointer_operation;
-/* The various readonly error string used by readonly_error. */
-typedef enum readonly_error_kind
-{
- /* assignment */
- REK_ASSIGNMENT,
- /* assignment (via 'asm' output) */
- REK_ASSIGNMENT_ASM,
- /* increment */
- REK_INCREMENT,
- /* decrement */
- REK_DECREMENT
-} readonly_error_kind;
-
/* Possible cases of expression list used by build_x_compound_expr_from_list. */
typedef enum expr_list_kind {
ELK_INIT, /* initializer */
@@ -5589,7 +5576,7 @@ extern void cxx_incomplete_type_error (const_tree, const_tree);
(cxx_incomplete_type_diagnostic ((V), (T), DK_ERROR))
extern tree error_not_base_type (tree, tree);
extern tree binfo_or_else (tree, tree);
-extern void readonly_error (tree, readonly_error_kind);
+extern void cxx_readonly_error (tree, enum lvalue_use);
extern void complete_type_check_abstract (tree);
extern int abstract_virtuals_error (tree, tree);
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index db0d0a1..7e42553 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -1317,7 +1317,7 @@ finish_asm_stmt (int volatile_p, tree string, tree output_operands,
effectively const. */
|| (CLASS_TYPE_P (TREE_TYPE (operand))
&& C_TYPE_FIELDS_READONLY (TREE_TYPE (operand)))))
- readonly_error (operand, REK_ASSIGNMENT_ASM);
+ cxx_readonly_error (operand, lv_asm);
constraint = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (t)));
oconstraints[i] = constraint;
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index f055bbc..edf1c13 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -5115,9 +5115,9 @@ cp_build_unary_op (enum tree_code code, tree xarg, int noconvert,
|| TREE_READONLY (arg))
{
if (complain & tf_error)
- readonly_error (arg, ((code == PREINCREMENT_EXPR
- || code == POSTINCREMENT_EXPR)
- ? REK_INCREMENT : REK_DECREMENT));
+ cxx_readonly_error (arg, ((code == PREINCREMENT_EXPR
+ || code == POSTINCREMENT_EXPR)
+ ? lv_increment : lv_decrement));
else
return error_mark_node;
}
@@ -6660,7 +6660,7 @@ cp_build_modify_expr (tree lhs, enum tree_code modifycode, tree rhs,
&& C_TYPE_FIELDS_READONLY (lhstype))))
{
if (complain & tf_error)
- readonly_error (lhs, REK_ASSIGNMENT);
+ cxx_readonly_error (lhs, lv_assign);
else
return error_mark_node;
}
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index 1c05314..3d65939 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -70,7 +70,7 @@ binfo_or_else (tree base, tree type)
value may not be changed thereafter. */
void
-readonly_error (tree arg, readonly_error_kind errstring)
+cxx_readonly_error (tree arg, enum lvalue_use errstring)
{
/* This macro is used to emit diagnostics to ensure that all format
@@ -81,16 +81,16 @@ readonly_error (tree arg, readonly_error_kind errstring)
do { \
switch (errstring) \
{ \
- case REK_ASSIGNMENT: \
+ case lv_assign: \
error(AS, ARG); \
break; \
- case REK_ASSIGNMENT_ASM: \
+ case lv_asm: \
error(ASM, ARG); \
break; \
- case REK_INCREMENT: \
+ case lv_increment: \
error (IN, ARG); \
break; \
- case REK_DECREMENT: \
+ case lv_decrement: \
error (DE, ARG); \
break; \
default: \
@@ -98,108 +98,36 @@ readonly_error (tree arg, readonly_error_kind errstring)
} \
} while (0)
- if (TREE_CODE (arg) == COMPONENT_REF)
- {
- if (TYPE_READONLY (TREE_TYPE (TREE_OPERAND (arg, 0))))
- ERROR_FOR_ASSIGNMENT (G_("assignment of "
- "data-member %qD in read-only structure"),
- G_("assignment (via 'asm' output) of "
- "data-member %qD in read-only structure"),
- G_("increment of "
- "data-member %qD in read-only structure"),
- G_("decrement of "
- "data-member %qD in read-only structure"),
- TREE_OPERAND (arg, 1));
- else
- ERROR_FOR_ASSIGNMENT (G_("assignment of "
- "read-only data-member %qD"),
- G_("assignment (via 'asm' output) of "
- "read-only data-member %qD"),
- G_("increment of "
- "read-only data-member %qD"),
- G_("decrement of "
- "read-only data-member %qD"),
- TREE_OPERAND (arg, 1));
- }
- else if (TREE_CODE (arg) == VAR_DECL)
- {
- if (DECL_LANG_SPECIFIC (arg)
- && DECL_IN_AGGR_P (arg)
- && !TREE_STATIC (arg))
- ERROR_FOR_ASSIGNMENT (G_("assignment of "
- "constant field %qD"),
- G_("assignment (via 'asm' output) of "
- "constant field %qD"),
- G_("increment of "
- "constant field %qD"),
- G_("decrement of "
- "constant field %qD"),
- arg);
- else
- ERROR_FOR_ASSIGNMENT (G_("assignment of "
- "read-only variable %qD"),
- G_("assignment (via 'asm' output) of "
- "read-only variable %qD"),
- G_("increment of "
- "read-only variable %qD"),
- G_("decrement of "
- "read-only variable %qD"),
- arg);
+ /* Handle C++-specific things first. */
- }
- else if (TREE_CODE (arg) == PARM_DECL)
+ if (TREE_CODE (arg) == VAR_DECL
+ && DECL_LANG_SPECIFIC (arg)
+ && DECL_IN_AGGR_P (arg)
+ && !TREE_STATIC (arg))
ERROR_FOR_ASSIGNMENT (G_("assignment of "
- "read-only parameter %qD"),
- G_("assignment (via 'asm' output) of "
- "read-only parameter %qD"),
- G_("increment of "
- "read-only parameter %qD"),
- G_("decrement of "
- "read-only parameter %qD"),
- arg);
+ "constant field %qD"),
+ G_("constant field %qD "
+ "used as %<asm%> output"),
+ G_("increment of "
+ "constant field %qD"),
+ G_("decrement of "
+ "constant field %qD"),
+ arg);
else if (TREE_CODE (arg) == INDIRECT_REF
&& TREE_CODE (TREE_TYPE (TREE_OPERAND (arg, 0))) == REFERENCE_TYPE
&& (TREE_CODE (TREE_OPERAND (arg, 0)) == VAR_DECL
|| TREE_CODE (TREE_OPERAND (arg, 0)) == PARM_DECL))
ERROR_FOR_ASSIGNMENT (G_("assignment of "
"read-only reference %qD"),
- G_("assignment (via 'asm' output) of "
- "read-only reference %qD"),
+ G_("read-only reference %qD "
+ "used as %<asm%> output"),
G_("increment of "
"read-only reference %qD"),
G_("decrement of "
"read-only reference %qD"),
TREE_OPERAND (arg, 0));
- else if (TREE_CODE (arg) == RESULT_DECL)
- ERROR_FOR_ASSIGNMENT (G_("assignment of "
- "read-only named return value %qD"),
- G_("assignment (via 'asm' output) of "
- "read-only named return value %qD"),
- G_("increment of "
- "read-only named return value %qD"),
- G_("decrement of "
- "read-only named return value %qD"),
- arg);
- else if (TREE_CODE (arg) == FUNCTION_DECL)
- ERROR_FOR_ASSIGNMENT (G_("assignment of "
- "function %qD"),
- G_("assignment (via 'asm' output) of "
- "function %qD"),
- G_("increment of "
- "function %qD"),
- G_("decrement of "
- "function %qD"),
- arg);
else
- ERROR_FOR_ASSIGNMENT (G_("assignment of "
- "read-only location %qE"),
- G_("assignment (via 'asm' output) of "
- "read-only location %qE"),
- G_("increment of "
- "read-only location %qE"),
- G_("decrement of "
- "read-only location %qE"),
- arg);
+ readonly_error (arg, errstring);
}