Commit ebeb2c24 by Shujing Zhao Committed by Shujing Zhao

cp-tree.h (impl_conv_void): New type.

/cp
2010-07-06  Shujing Zhao  <pearly.zhao@oracle.com>

        * cp-tree.h (impl_conv_void): New type.
        (convert_to_void): Adjust prototype.
        * cvt.c (convert_to_void): Use impl_conv_void, emit and adjust the
        diagnostic for easy translation. Change caller.
        * typeck.c: Update call to convert_to_void.
        * semantics.c: Likewise.
        * init.c: Likewise.

/testsuite
2010-07-06  Shujing Zhao  <pearly.zhao@oracle.com>

        * g++.dg/warn/noeffect2.C: Adjust expected warning.
        * g++.dg/warn/volatile1.C: Likewise.
        * g++.dg/template/warn1.C: Likewise.

From-SVN: r161863
parent c021f10b
2010-07-06 Shujing Zhao <pearly.zhao@oracle.com>
* cp-tree.h (impl_conv_void): New type.
(convert_to_void): Adjust prototype.
* cvt.c (convert_to_void): Use impl_conv_void, emit and adjust the
diagnostic for easy translation. Change caller.
* typeck.c: Update call to convert_to_void.
* semantics.c: Likewise.
* init.c: Likewise.
2010-07-05 Nathan Froyd <froydnj@codesourcery.com>
* decl.c (cp_finish_decl): Call add_local_decl.
......
......@@ -435,6 +435,17 @@ typedef enum impl_conv_rhs {
ICR_ASSIGN /* assignment */
} impl_conv_rhs;
/* Possible cases of implicit or explicit bad conversions to void. */
typedef enum impl_conv_void {
ICV_CAST, /* (explicit) conversion to void */
ICV_SECOND_OF_COND, /* second operand of conditional expression */
ICV_THIRD_OF_COND, /* third operand of conditional expression */
ICV_RIGHT_OF_COMMA, /* right operand of comma operator */
ICV_LEFT_OF_COMMA, /* left operand of comma operator */
ICV_STATEMENT, /* statement */
ICV_THIRD_IN_FOR /* for increment expression */
} impl_conv_void;
/* Macros for access to language-specific slots in an identifier. */
#define IDENTIFIER_NAMESPACE_BINDINGS(NODE) \
......@@ -4697,8 +4708,8 @@ extern tree ocp_convert (tree, tree, int, int);
extern tree cp_convert (tree, tree);
extern tree cp_convert_and_check (tree, tree);
extern tree cp_fold_convert (tree, tree);
extern tree convert_to_void (tree, const char */*implicit context*/,
tsubst_flags_t);
extern tree convert_to_void (tree, impl_conv_void,
tsubst_flags_t);
extern tree convert_force (tree, tree, int);
extern tree build_expr_type_conversion (int, tree, bool);
extern tree type_promotes_to (tree);
......
......@@ -1374,7 +1374,7 @@ expand_default_init (tree binfo, tree true_exp, tree exp, tree init, int flags,
release_tree_vector (parms);
if (TREE_SIDE_EFFECTS (rval))
finish_expr_stmt (convert_to_void (rval, NULL, complain));
finish_expr_stmt (convert_to_void (rval, ICV_CAST, complain));
}
/* This function is responsible for initializing EXP with INIT
......@@ -2726,7 +2726,7 @@ build_vec_delete_1 (tree base, tree maxindex, tree type,
/* Pre-evaluate the SAVE_EXPR outside of the BIND_EXPR. */
body = build2 (COMPOUND_EXPR, void_type_node, base, body);
return convert_to_void (body, /*implicit=*/NULL, tf_warning_or_error);
return convert_to_void (body, ICV_CAST, tf_warning_or_error);
}
/* Create an unnamed variable of the indicated TYPE. */
......
......@@ -607,10 +607,10 @@ finish_expr_stmt (tree expr)
{
if (warn_sequence_point)
verify_sequence_points (expr);
expr = convert_to_void (expr, "statement", tf_warning_or_error);
expr = convert_to_void (expr, ICV_STATEMENT, tf_warning_or_error);
}
else if (!type_dependent_expression_p (expr))
convert_to_void (build_non_dependent_expr (expr), "statement",
convert_to_void (build_non_dependent_expr (expr), ICV_STATEMENT,
tf_warning_or_error);
if (check_for_bare_parameter_packs (expr))
......@@ -868,11 +868,11 @@ finish_for_expr (tree expr, tree for_stmt)
{
if (warn_sequence_point)
verify_sequence_points (expr);
expr = convert_to_void (expr, "3rd expression in for",
expr = convert_to_void (expr, ICV_THIRD_IN_FOR,
tf_warning_or_error);
}
else if (!type_dependent_expression_p (expr))
convert_to_void (build_non_dependent_expr (expr), "3rd expression in for",
convert_to_void (build_non_dependent_expr (expr), ICV_THIRD_IN_FOR,
tf_warning_or_error);
expr = maybe_cleanup_point_expr_void (expr);
if (check_for_bare_parameter_packs (expr))
......
......@@ -5591,7 +5591,7 @@ build_compound_expr (location_t loc ATTRIBUTE_UNUSED, tree lhs, tree rhs)
tree
cp_build_compound_expr (tree lhs, tree rhs, tsubst_flags_t complain)
{
lhs = convert_to_void (lhs, "left-hand operand of comma", complain);
lhs = convert_to_void (lhs, ICV_LEFT_OF_COMMA, complain);
if (lhs == error_mark_node || rhs == error_mark_node)
return error_mark_node;
......@@ -5858,7 +5858,7 @@ build_static_cast_1 (tree type, tree expr, bool c_cast_p,
Any expression can be explicitly converted to type cv void. */
if (TREE_CODE (type) == VOID_TYPE)
return convert_to_void (expr, /*implicit=*/NULL, complain);
return convert_to_void (expr, ICV_CAST, complain);
/* [expr.static.cast]
......
2010-07-06 Shujing Zhao <pearly.zhao@oracle.com>
* g++.dg/warn/noeffect2.C: Adjust expected warning.
* g++.dg/warn/volatile1.C: Likewise.
* g++.dg/template/warn1.C: Likewise.
2010-07-05 H.J. Lu <hongjiu.lu@intel.com>
AVX Programming Reference (June, 2010)
......
......@@ -9,8 +9,8 @@
template <class T> void Foo(T i)
{
i++, i++;
i, i++; // { dg-warning "left-hand operand" "" }
i++, i; // { dg-warning "right-hand operand" "" }
i, i++; // { dg-warning "left operand" "" }
i++, i; // { dg-warning "right operand" "" }
for (;; --i, ++i)
;
}
......
......@@ -10,11 +10,11 @@
extern "C" void FormatDisk();
template <class T>
struct C {
C(){ FormatDisk(), 0; } // { dg-warning "right-hand operand of comma" "" }
C(){ FormatDisk(), 0; } // { dg-warning "right operand of comma" "" }
};
template struct C<int>; // { dg-message "instantiated" }
template <class T>
void f() { FormatDisk(), 0; } // { dg-warning "right-hand operand of comma" "" }
void f() { FormatDisk(), 0; } // { dg-warning "right operand of comma" "" }
template void f<int> (); // { dg-message "instantiated" }
void g() { FormatDisk(), 0; } // { dg-warning "right-hand operand of comma" "" }
void g() { FormatDisk(), 0; } // { dg-warning "right operand of comma" "" }
......@@ -8,5 +8,5 @@ struct A
};
void A::baz() volatile
{
*this; // { dg-warning "will not be accessed" }
*this; // { dg-warning "indirection will not access" }
}
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