diff options
author | Matt Austern <austern@apple.com> | 2005-02-03 00:02:10 +0000 |
---|---|---|
committer | Matt Austern <austern@gcc.gnu.org> | 2005-02-03 00:02:10 +0000 |
commit | 100d337a9d06bbc8f367e37debbe69610b04e72f (patch) | |
tree | 54f1d79812354b990fbbfe75895aedd5f2372e9c /gcc/cp/pt.c | |
parent | 89d12f5d49829d3dbf9a78040b88df833923c0df (diff) | |
download | gcc-100d337a9d06bbc8f367e37debbe69610b04e72f.zip gcc-100d337a9d06bbc8f367e37debbe69610b04e72f.tar.gz gcc-100d337a9d06bbc8f367e37debbe69610b04e72f.tar.bz2 |
re PR c++/19628 (g++ no longer accepts __builtin_constant_p in constant-expressions)
PR c++/19628
* cp-tree.h (builtin_valid_in_constant_expr_p): Declare.
* parser.c (cp_parser_postfix_expression): Accept function call in constant expression if builtin_valid_in_constant_expr_p is true for that function.
* pt.c (value_dependent_expression_p): Handle CALL_EXPRs properly.
* semantics.c (finish_id_expression): Accept function call in constant expression if builtin_valid_in_constant_expr_p is true for that function.
* tree.c (builtin_valid_in_constant_expr_p): New.
* g++/ext/builtin7.C: New.
* g++/ext/builtin8.C: New.
From-SVN: r94635
Diffstat (limited to 'gcc/cp/pt.c')
-rw-r--r-- | gcc/cp/pt.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 0e6ce13..d0cd229 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -12020,6 +12020,36 @@ value_dependent_expression_p (tree expression) if (TREE_CODE (expression) == COMPONENT_REF) return (value_dependent_expression_p (TREE_OPERAND (expression, 0)) || value_dependent_expression_p (TREE_OPERAND (expression, 1))); + + /* A CALL_EXPR is value-dependent if any argument is + value-dependent. Why do we have to handle CALL_EXPRs in this + function at all? First, some function calls, those for which + value_dependent_expression_p is true, man appear in constant + expressions. Second, there appear to be bugs which result in + other CALL_EXPRs reaching this point. */ + if (TREE_CODE (expression) == CALL_EXPR) + { + tree function = TREE_OPERAND (expression, 0); + tree args = TREE_OPERAND (expression, 1); + + if (value_dependent_expression_p (function)) + return true; + else if (! args) + return false; + else if (TREE_CODE (args) == TREE_LIST) + { + do + { + if (value_dependent_expression_p (TREE_VALUE (args))) + return true; + args = TREE_CHAIN (args); + } + while (args); + return false; + } + else + return value_dependent_expression_p (args); + } /* A constant expression is value-dependent if any subexpression is value-dependent. */ if (EXPR_P (expression)) |