From aa0a659ca69cf092fcfb6ebb58a749b63a04be48 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Thu, 14 Aug 2014 20:12:32 +0000 Subject: [PATCH] typeck.c (composite_pointer_type, [...]): When a pedwarn is suppressed under SFINAE, return error_mark_node. 2014-08-14 Paolo Carlini * 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 --- gcc/cp/ChangeLog | 9 +++++++ gcc/cp/typeck.c | 77 ++++++++++++++++++++++++++++++++++---------------------- 2 files changed, 56 insertions(+), 30 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a256953..54ed213 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +2014-08-14 Paolo Carlini + + * 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 PR c++/62101 diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 353d921..fa3283d 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -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 % and pointer-to-function"); - break; - case CPO_CONVERSION: - pedwarn (input_location, OPT_Wpedantic, - "ISO C++ forbids conversion between " - "pointer of type % and pointer-to-function"); - break; - case CPO_CONDITIONAL_EXPR: - pedwarn (input_location, OPT_Wpedantic, - "ISO C++ forbids conditional expression between " - "pointer of type % 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 % and pointer-to-function"); + break; + case CPO_CONVERSION: + pedwarn (input_location, OPT_Wpedantic, + "ISO C++ forbids conversion between pointer " + "of type % and pointer-to-function"); + break; + case CPO_CONDITIONAL_EXPR: + pedwarn (input_location, OPT_Wpedantic, + "ISO C++ forbids conditional expression between " + "pointer of type % 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 **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 -- 2.7.4