Commit aa0a659c by Paolo Carlini Committed by Paolo Carlini

typeck.c (composite_pointer_type, [...]): When a pedwarn is suppressed under…

typeck.c (composite_pointer_type, [...]): When a pedwarn is suppressed under SFINAE, return error_mark_node.

2014-08-14  Paolo Carlini  <paolo.carlini@oracle.com>

	* typeck.c (composite_pointer_type, cxx_sizeof_or_alignof_type,
	cp_build_array_ref, cp_build_function_call_vec): When a
	pedwarn is suppressed under SFINAE, return error_mark_node.

	* typeck.c (cxx_sizeof_or_alignof_type): Fix complain &
	tf_warning_or_error, where complain is a bool, glitch.

From-SVN: r213983
parent 0ee9c843
2014-08-14 Paolo Carlini <paolo.carlini@oracle.com>
* typeck.c (composite_pointer_type, cxx_sizeof_or_alignof_type,
cp_build_array_ref, cp_build_function_call_vec): When a
pedwarn is suppressed under SFINAE, return error_mark_node.
* typeck.c (cxx_sizeof_or_alignof_type): Fix complain &
tf_warning_or_error, where complain is a bool, glitch.
2014-08-14 Ville Voutilainen <ville.voutilainen@gmail.com>
PR c++/62101
......
......@@ -597,28 +597,34 @@ composite_pointer_type (tree t1, tree t2, tree arg1, tree arg2,
tree attributes;
tree result_type;
if (TYPE_PTRFN_P (t2) && (complain & tf_error))
{
switch (operation)
{
case CPO_COMPARISON:
pedwarn (input_location, OPT_Wpedantic,
"ISO C++ forbids comparison between "
"pointer of type %<void *%> and pointer-to-function");
break;
case CPO_CONVERSION:
pedwarn (input_location, OPT_Wpedantic,
"ISO C++ forbids conversion between "
"pointer of type %<void *%> and pointer-to-function");
break;
case CPO_CONDITIONAL_EXPR:
pedwarn (input_location, OPT_Wpedantic,
"ISO C++ forbids conditional expression between "
"pointer of type %<void *%> and pointer-to-function");
break;
default:
gcc_unreachable ();
}
if (TYPE_PTRFN_P (t2))
{
if (complain & tf_error)
{
switch (operation)
{
case CPO_COMPARISON:
pedwarn (input_location, OPT_Wpedantic,
"ISO C++ forbids comparison between pointer "
"of type %<void *%> and pointer-to-function");
break;
case CPO_CONVERSION:
pedwarn (input_location, OPT_Wpedantic,
"ISO C++ forbids conversion between pointer "
"of type %<void *%> and pointer-to-function");
break;
case CPO_CONDITIONAL_EXPR:
pedwarn (input_location, OPT_Wpedantic,
"ISO C++ forbids conditional expression between "
"pointer of type %<void *%> and "
"pointer-to-function");
break;
default:
gcc_unreachable ();
}
}
else
return error_mark_node;
}
result_type
= cp_build_qualified_type (void_type_node,
......@@ -1536,6 +1542,8 @@ cxx_sizeof_or_alignof_type (tree type, enum tree_code op, bool complain)
pedwarn (input_location, OPT_Wpointer_arith,
"invalid application of %qs to a member function",
operator_name_info[(int) op].name);
else
return error_mark_node;
value = size_one_node;
}
......@@ -1561,7 +1569,7 @@ cxx_sizeof_or_alignof_type (tree type, enum tree_code op, bool complain)
if (cxx_dialect >= cxx1y && array_of_runtime_bound_p (type)
&& (flag_iso || warn_vla > 0))
{
if (complain & tf_warning_or_error)
if (complain)
pedwarn (input_location, OPT_Wvla,
"taking sizeof array of runtime bound");
else
......@@ -3129,9 +3137,14 @@ cp_build_array_ref (location_t loc, tree array, tree idx,
return error_mark_node;
}
if (!lvalue_p (array) && (complain & tf_error))
pedwarn (loc, OPT_Wpedantic,
"ISO C++ forbids subscripting non-lvalue array");
if (!lvalue_p (array))
{
if (complain & tf_error)
pedwarn (loc, OPT_Wpedantic,
"ISO C++ forbids subscripting non-lvalue array");
else
return error_mark_node;
}
/* Note in C++ it is valid to subscript a `register' array, since
it is valid to take the address of something with that
......@@ -3467,10 +3480,14 @@ cp_build_function_call_vec (tree function, vec<tree, va_gc> **params,
fndecl = function;
/* Convert anything with function type to a pointer-to-function. */
if (DECL_MAIN_P (function) && (complain & tf_error))
pedwarn (input_location, OPT_Wpedantic,
"ISO C++ forbids calling %<::main%> from within program");
if (DECL_MAIN_P (function))
{
if (complain & tf_error)
pedwarn (input_location, OPT_Wpedantic,
"ISO C++ forbids calling %<::main%> from within program");
else
return error_mark_node;
}
function = build_addr_func (function, complain);
}
else
......
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