]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
There can be only one ref qualifier at most.
authorEd Smith-Rowland <3dw4rd@verizon.net>
Fri, 5 Apr 2013 11:38:09 +0000 (11:38 +0000)
committerEdward Smith-Rowland <emsr@gcc.gnu.org>
Fri, 5 Apr 2013 11:38:09 +0000 (11:38 +0000)
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

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/ref-qual-multi-neg.C [new file with mode: 0644]

index d039f8bdaf33db660c772b0cb8f07362220e65fd..dc6761033028c3314a714a6b55814231ef43aa60 100644 (file)
@@ -1,3 +1,8 @@
+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>
 
        * cp-tree.h (FUNCTION_OR_METHOD_TYPE_CHECK): Remove.
index 05c03f45d27c658a24654efb0ca997e8f33ffa23..ed8eac8cc4e007a57349ac3443c340c33065877f 100644 (file)
@@ -2020,7 +2020,7 @@ static cp_cv_quals cp_parser_cv_qualifier_seq_opt
   (cp_parser *);
 static cp_virt_specifiers cp_parser_virt_specifier_seq_opt
   (cp_parser *);
-static cp_ref_qualifier cp_parser_ref_qualifier_seq_opt
+static cp_ref_qualifier cp_parser_ref_qualifier_opt
   (cp_parser *);
 static tree cp_parser_late_return_type_opt
   (cp_parser *, cp_cv_quals);
@@ -16463,7 +16463,7 @@ cp_parser_direct_declarator (cp_parser* parser,
                  /* Parse the cv-qualifier-seq.  */
                  cv_quals = cp_parser_cv_qualifier_seq_opt (parser);
                  /* 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.  */
                  exception_specification
                    = cp_parser_exception_specification_opt (parser);
@@ -17031,25 +17031,46 @@ cp_parser_cv_qualifier_seq_opt (cp_parser* parser)
    Returns cp_ref_qualifier representing 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_token *token = cp_lexer_peek_token (parser->lexer);
-  switch (token->type)
+
+  while (true)
     {
-    case CPP_AND:
-      ref_qual = REF_QUAL_LVALUE;
-      break;
-    case CPP_AND_AND:
-      ref_qual = REF_QUAL_RVALUE;
-      break;
+      cp_ref_qualifier curr_ref_qual = REF_QUAL_NONE;
+      cp_token *token = cp_lexer_peek_token (parser->lexer);
+
+      switch (token->type)
+       {
+       case CPP_AND:
+         curr_ref_qual = REF_QUAL_LVALUE;
+         break;
+
+       case CPP_AND_AND:
+         curr_ref_qual = REF_QUAL_RVALUE;
+         break;
+
+       default:
+         curr_ref_qual = REF_QUAL_NONE;
+         break;
+       }
+
+      if (!curr_ref_qual)
+       break;
+      else if (ref_qual)
+       {
+         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);
+       }
     }
 
   if (ref_qual)
-    {
-      maybe_warn_cpp0x (CPP0X_REF_QUALIFIER);
-      cp_lexer_consume_token (parser->lexer);
-    }
+    maybe_warn_cpp0x (CPP0X_REF_QUALIFIER);
 
   return ref_qual;
 }
index 175977573e48669f9d894d23f48f624a5888caaf..e63b313c52e993d7edd10616812efbbdf4364203 100644 (file)
@@ -1,3 +1,7 @@
+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>
 
        PR fortran/40881
diff --git a/gcc/testsuite/g++.dg/cpp0x/ref-qual-multi-neg.C b/gcc/testsuite/g++.dg/cpp0x/ref-qual-multi-neg.C
new file mode 100644 (file)
index 0000000..5be8942
--- /dev/null
@@ -0,0 +1,7 @@
+// { dg-require-effective-target c++11 }
+
+class Foo
+{
+public:
+  void bar() const && & { }  // { dg-error "multiple ref-qualifiers" }
+};