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
This commit is contained in:
Jason Merrill 2013-03-16 22:39:51 -04:00 committed by Jason Merrill
parent bc0c6b150e
commit d14d53ad65
3 changed files with 30 additions and 1 deletions

View File

@ -1,5 +1,9 @@
2013-03-16 Jason Merrill <jason@redhat.com> 2013-03-16 Jason Merrill <jason@redhat.com>
PR c++/55931
* parser.c (cp_parser_template_argument): Don't
fold_non_dependent_expr.
* parser.c (cp_parser_lambda_declarator_opt): Use * parser.c (cp_parser_lambda_declarator_opt): Use
cp_parser_trailing_type_id. cp_parser_trailing_type_id.

View File

@ -13335,7 +13335,6 @@ cp_parser_template_argument (cp_parser* parser)
argument = cp_parser_constant_expression (parser, argument = cp_parser_constant_expression (parser,
/*allow_non_constant_p=*/false, /*allow_non_constant_p=*/false,
/*non_constant_p=*/NULL); /*non_constant_p=*/NULL);
argument = fold_non_dependent_expr (argument);
if (!maybe_type_id) if (!maybe_type_id)
return argument; return argument;
if (!cp_parser_next_token_ends_template_argument_p (parser)) if (!cp_parser_next_token_ends_template_argument_p (parser))

View File

@ -0,0 +1,26 @@
// PR c++/55931
// { dg-do compile { target c++11 } }
#include <type_traits>
template<typename Type>
class Test
{
public:
constexpr Test(const Type val) : _value(val) {}
constexpr Type get() const {return _value;}
static void test()
{
static constexpr Test<int> x(42);
std::integral_constant<int, x.get()> i; // This is not working
}
protected:
Type _value;
};
int main()
{
static constexpr Test<int> x(42);
std::integral_constant<int, x.get()> i; // This is working
Test<double>::test();
}