aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/tree.c
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2016-05-03 21:15:28 +0000
committerMartin Sebor <msebor@gcc.gnu.org>2016-05-03 15:15:28 -0600
commitb25aad5fda6c3efbb83980fb0f4fb0e2ddd38216 (patch)
tree0909668e48da930feebd5b9147810cbe08e38f6c /gcc/cp/tree.c
parent9663f8f74821638d2f2ef1a333ec4e937c3c6040 (diff)
downloadgcc-b25aad5fda6c3efbb83980fb0f4fb0e2ddd38216.zip
gcc-b25aad5fda6c3efbb83980fb0f4fb0e2ddd38216.tar.gz
gcc-b25aad5fda6c3efbb83980fb0f4fb0e2ddd38216.tar.bz2
PR c++/66561 - __builtin_LINE at al. should yield constant expressions
PR c++/66561 - __builtin_LINE at al. should yield constant expressions PR c++/66639 - declare __func__, __FUNCTION__ & __PRETTY_FUNCTION__ constexpr gcc/testsuite/ChangeLog: 2016-05-03 Martin Sebor <msebor@redhat.com> PR c++/66561 * c-c++-common/builtin_location.c: New test. * g++.dg/cpp1y/builtin_location.C: New test. gcc/cp/ChangeLog: 2016-05-03 Martin Sebor <msebor@redhat.com> PR c++/66561 * tree.c (builtin_valid_in_constant_expr_p): Treat BUILT_IN_FILE, BUILT_IN_FUNCTION, and BUILT_IN_LINE as constant expressions. gcc/ChangeLog: 2016-05-03 Martin Sebor <msebor@redhat.com> PR c++/66561 * builtins.c (fold_builtin_FILE): New function. (fold_builtin_FUNCTION, fold_builtin_LINE): New functions. (fold_builtin_0): Call them. * gimplify.c (gimplify_call_expr): Remove the handling of BUILT_IN_FILE, BUILT_IN_FUNCTION, and BUILT_IN_LINE. PR c++/66561 * doc/extend.texi (Other Builtins): Update __builtin_FILE, __builtin_FUNCTION, and __builtin_LINE to reflect they yield constants. PR c++/66639 * doc/extend.texi (Function Names as Strings): Update __func__, __FUNCTION__, __PRETTY_FUNCTION__ to reflect they evaluate to constants. From-SVN: r235845
Diffstat (limited to 'gcc/cp/tree.c')
-rw-r--r--gcc/cp/tree.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index d7e9c7b..57fc5c1 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -346,10 +346,16 @@ builtin_valid_in_constant_expr_p (const_tree decl)
return false;
switch (DECL_FUNCTION_CODE (decl))
{
- case BUILT_IN_CONSTANT_P:
- case BUILT_IN_ATOMIC_ALWAYS_LOCK_FREE:
+ /* These always have constant results like the corresponding
+ macros/symbol. */
+ case BUILT_IN_FILE:
+ case BUILT_IN_FUNCTION:
+ case BUILT_IN_LINE:
+
/* These have constant results even if their operands are
non-constant. */
+ case BUILT_IN_CONSTANT_P:
+ case BUILT_IN_ATOMIC_ALWAYS_LOCK_FREE:
return true;
default:
return false;