diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c0e1cf4dd5f..4de8ba158db 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2012-01-10 Jason Merrill + + PR c++/51433 + * semantics.c (cxx_eval_call_expression): Always retry previously + non-constant expressions. + 2012-01-06 Jason Merrill DR 686 diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index fbb74e1e8de..2c351bee020 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -6576,7 +6576,7 @@ cxx_eval_call_expression (const constexpr_call *old_call, tree t, else { result = entry->result; - if (!result || (result == error_mark_node && !allow_non_constant)) + if (!result || result == error_mark_node) result = (cxx_eval_constant_expression (&new_call, new_call.fundef->body, allow_non_constant, addr, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f05d3e5182d..0afad2796a1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-01-10 Jason Merrill + + PR c++/51433 + * g++.dg/cpp0x/constexpr-cache1.C: New. + 2012-01-10 Richard Guenther PR tree-optimization/51801 diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-cache1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-cache1.C new file mode 100644 index 00000000000..b6d7b647139 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-cache1.C @@ -0,0 +1,9 @@ +// PR c++/51433 +// { dg-options -std=c++0x } + +constexpr int f(); +constexpr int g() { return f(); } +extern const int n = g(); // dynamic initialization +constexpr int f() { return 42; } +extern const int m = g(); +static_assert(m == 42, "m == 42");