aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/expr.c
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2015-09-03 16:23:11 +0000
committerMartin Sebor <msebor@gcc.gnu.org>2015-09-03 10:23:11 -0600
commit1807ffc1a51df83a3ad26ad1b56ef0bbe8a7e494 (patch)
treeb48648309af44524f8927ac7e65ea6eb947a7d9e /gcc/cp/expr.c
parent97875f4a942078f65739718c129b0b6289c4b43b (diff)
downloadgcc-1807ffc1a51df83a3ad26ad1b56ef0bbe8a7e494.zip
gcc-1807ffc1a51df83a3ad26ad1b56ef0bbe8a7e494.tar.gz
gcc-1807ffc1a51df83a3ad26ad1b56ef0bbe8a7e494.tar.bz2
re PR c/66516 (missing diagnostic on taking the address of a builtin function)
gcc/ChangeLog 2015-09-03 Martin Sebor <msebor@redhat.com> PR c/66516 * doc/extend.texi (Other Builtins): Document when the address of a built-in function can be taken. gcc/c-family/ChangeLog 2015-09-03 Martin Sebor <msebor@redhat.com> PR c/66516 * c-common.h (c_decl_implicit, reject_gcc_builtin): Declare new functions. * c-common.c (reject_gcc_builtin): Define. gcc/c/ChangeLog 2015-09-03 Martin Sebor <msebor@redhat.com> PR c/66516 * c/c-typeck.c (convert_arguments, parser_build_unary_op) (build_conditional_expr, c_cast_expr, convert_for_assignment) (build_binary_op, _objc_common_truthvalue_conversion): Call reject_gcc_builtin. (c_decl_implicit): Define. gcc/cp/ChangeLog 2015-09-03 Martin Sebor <msebor@redhat.com> PR c/66516 * cp/cp-tree.h (mark_rvalue_use, decay_conversion): Add new argument(s). * cp/expr.c (mark_rvalue_use): Use new argument. * cp/call.c (build_addr_func): Call decay_conversion with new argument. * cp/pt.c (convert_template_argument): Call reject_gcc_builtin. * cp/typeck.c (decay_conversion): Use new argument. (c_decl_implicit): Define. gcc/testsuite/ChangeLog 2015-09-03 Martin Sebor <msebor@redhat.com> PR c/66516 * g++.dg/addr_builtin-1.C: New test. * gcc.dg/addr_builtin-1.c: New test. From-SVN: r227458
Diffstat (limited to 'gcc/cp/expr.c')
-rw-r--r--gcc/cp/expr.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/gcc/cp/expr.c b/gcc/cp/expr.c
index 6d2d658..71dec3d 100644
--- a/gcc/cp/expr.c
+++ b/gcc/cp/expr.c
@@ -91,18 +91,24 @@ cplus_expand_constant (tree cst)
return cst;
}
-/* Called whenever an expression is used
- in a rvalue context. */
-
+/* Called whenever the expression EXPR is used in an rvalue context.
+ When REJECT_BUILTIN is true the expression is checked to make sure
+ it doesn't make it possible to obtain the address of a GCC built-in
+ function with no library fallback (or any of its bits, such as in
+ a conversion to bool). */
tree
-mark_rvalue_use (tree expr)
+mark_rvalue_use (tree expr,
+ location_t loc /* = UNKNOWN_LOCATION */,
+ bool reject_builtin /* = true */)
{
+ if (reject_builtin && reject_gcc_builtin (expr, loc))
+ return error_mark_node;
+
mark_exp_read (expr);
return expr;
}
-/* Called whenever an expression is used
- in a lvalue context. */
+/* Called whenever an expression is used in an lvalue context. */
tree
mark_lvalue_use (tree expr)