Commit 45416e08 by Ed Smith-Rowland Committed by Edward Smith-Rowland

There can be only one ref qualifier at most.

gcc/cp:
2013-04-05  Ed Smith-Rowland  <3dw4rd@verizon.net>

	* g++.dg/cpp0x/ref-qual-multi-neg.C: New test.

gcc/testsuite:
2013-04-05  Ed Smith-Rowland  <3dw4rd@verizon.net>

	* parser.c (cp_parser_ref_qualifier_seq_opt): Move to
	cp_parser_ref_qualifier_opt.  Error if more than one ref-qual found.

From-SVN: r197514
parent 8456d78a
2013-04-05 Ed Smith-Rowland <3dw4rd@verizon.net>
* parser.c (cp_parser_ref_qualifier_seq_opt): Move to
cp_parser_ref_qualifier_opt. Error if more than one ref-qual found.
2013-04-03 Jason Merrill <jason@redhat.com> 2013-04-03 Jason Merrill <jason@redhat.com>
* cp-tree.h (FUNCTION_OR_METHOD_TYPE_CHECK): Remove. * cp-tree.h (FUNCTION_OR_METHOD_TYPE_CHECK): Remove.
......
...@@ -2020,7 +2020,7 @@ static cp_cv_quals cp_parser_cv_qualifier_seq_opt ...@@ -2020,7 +2020,7 @@ static cp_cv_quals cp_parser_cv_qualifier_seq_opt
(cp_parser *); (cp_parser *);
static cp_virt_specifiers cp_parser_virt_specifier_seq_opt static cp_virt_specifiers cp_parser_virt_specifier_seq_opt
(cp_parser *); (cp_parser *);
static cp_ref_qualifier cp_parser_ref_qualifier_seq_opt static cp_ref_qualifier cp_parser_ref_qualifier_opt
(cp_parser *); (cp_parser *);
static tree cp_parser_late_return_type_opt static tree cp_parser_late_return_type_opt
(cp_parser *, cp_cv_quals); (cp_parser *, cp_cv_quals);
...@@ -16463,7 +16463,7 @@ cp_parser_direct_declarator (cp_parser* parser, ...@@ -16463,7 +16463,7 @@ cp_parser_direct_declarator (cp_parser* parser,
/* Parse the cv-qualifier-seq. */ /* Parse the cv-qualifier-seq. */
cv_quals = cp_parser_cv_qualifier_seq_opt (parser); cv_quals = cp_parser_cv_qualifier_seq_opt (parser);
/* Parse the ref-qualifier. */ /* Parse the ref-qualifier. */
ref_qual = cp_parser_ref_qualifier_seq_opt (parser); ref_qual = cp_parser_ref_qualifier_opt (parser);
/* And the exception-specification. */ /* And the exception-specification. */
exception_specification exception_specification
= cp_parser_exception_specification_opt (parser); = cp_parser_exception_specification_opt (parser);
...@@ -17031,25 +17031,46 @@ cp_parser_cv_qualifier_seq_opt (cp_parser* parser) ...@@ -17031,25 +17031,46 @@ cp_parser_cv_qualifier_seq_opt (cp_parser* parser)
Returns cp_ref_qualifier representing ref-qualifier. */ Returns cp_ref_qualifier representing ref-qualifier. */
static cp_ref_qualifier static cp_ref_qualifier
cp_parser_ref_qualifier_seq_opt (cp_parser* parser) cp_parser_ref_qualifier_opt (cp_parser* parser)
{ {
cp_ref_qualifier ref_qual = REF_QUAL_NONE; cp_ref_qualifier ref_qual = REF_QUAL_NONE;
while (true)
{
cp_ref_qualifier curr_ref_qual = REF_QUAL_NONE;
cp_token *token = cp_lexer_peek_token (parser->lexer); cp_token *token = cp_lexer_peek_token (parser->lexer);
switch (token->type) switch (token->type)
{ {
case CPP_AND: case CPP_AND:
ref_qual = REF_QUAL_LVALUE; curr_ref_qual = REF_QUAL_LVALUE;
break; break;
case CPP_AND_AND: case CPP_AND_AND:
ref_qual = REF_QUAL_RVALUE; curr_ref_qual = REF_QUAL_RVALUE;
break;
default:
curr_ref_qual = REF_QUAL_NONE;
break; break;
} }
if (ref_qual) if (!curr_ref_qual)
break;
else if (ref_qual)
{ {
maybe_warn_cpp0x (CPP0X_REF_QUALIFIER); error_at (token->location, "multiple ref-qualifiers");
cp_lexer_purge_token (parser->lexer);
}
else
{
ref_qual = curr_ref_qual;
cp_lexer_consume_token (parser->lexer); cp_lexer_consume_token (parser->lexer);
} }
}
if (ref_qual)
maybe_warn_cpp0x (CPP0X_REF_QUALIFIER);
return ref_qual; return ref_qual;
} }
......
2013-04-05 Ed Smith-Rowland <3dw4rd@verizon.net>
* g++.dg/cpp0x/ref-qual-multi-neg.C: New test.
2013-04-04 Janus Weil <janus@gcc.gnu.org> 2013-04-04 Janus Weil <janus@gcc.gnu.org>
PR fortran/40881 PR fortran/40881
......
// { dg-require-effective-target c++11 }
class Foo
{
public:
void bar() const && & { } // { dg-error "multiple ref-qualifiers" }
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment