From d14d53ad6501853b2471ad90ead6eace803226a7 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Sat, 16 Mar 2013 22:39:51 -0400 Subject: [PATCH] re PR c++/55931 ([C++11] Constexpr member function inside a static member is not working) PR c++/55931 * parser.c (cp_parser_template_argument): Don't fold_non_dependent_expr. From-SVN: r196746 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/parser.c | 1 - gcc/testsuite/g++.dg/cpp0x/constexpr-template4.C | 26 ++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/constexpr-template4.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e6dec02..f6f1521 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2013-03-16 Jason Merrill + PR c++/55931 + * parser.c (cp_parser_template_argument): Don't + fold_non_dependent_expr. + * parser.c (cp_parser_lambda_declarator_opt): Use cp_parser_trailing_type_id. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 8b6dbe1..0222e90 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -13335,7 +13335,6 @@ cp_parser_template_argument (cp_parser* parser) argument = cp_parser_constant_expression (parser, /*allow_non_constant_p=*/false, /*non_constant_p=*/NULL); - argument = fold_non_dependent_expr (argument); if (!maybe_type_id) return argument; if (!cp_parser_next_token_ends_template_argument_p (parser)) diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-template4.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-template4.C new file mode 100644 index 0000000..7adcae8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-template4.C @@ -0,0 +1,26 @@ +// PR c++/55931 +// { dg-do compile { target c++11 } } + +#include + +template +class Test +{ + public: + constexpr Test(const Type val) : _value(val) {} + constexpr Type get() const {return _value;} + static void test() + { + static constexpr Test x(42); + std::integral_constant i; // This is not working + } + protected: + Type _value; +}; + +int main() +{ + static constexpr Test x(42); + std::integral_constant i; // This is working + Test::test(); +} -- 2.7.4