public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* PR c++/36475 [gomp] register keyword in openmp handled for-loop fails
@ 2008-10-26 19:26 Manuel López-Ibáñez
  2009-05-03 16:53 ` Manuel López-Ibáñez
  0 siblings, 1 reply; 3+ messages in thread
From: Manuel López-Ibáñez @ 2008-10-26 19:26 UTC (permalink / raw)
  To: Gcc Patch List

[-- Attachment #1: Type: text/plain, Size: 651 bytes --]

If you can imagine testcases where this approach may produce worse
results than the current code, please let me know. Notice that the new
cases should only affect invalid code. For valid code I think the
results should be the same as jumping directly to default.

Bootstrapped and regression tested on x86_64-unknown-linux-gnu with
--enable-languages=all,obj-c++ --enable-decimal-float.

OK for trunk?

2008-10-26  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	PR c++/pr36475
cp/
	* parser.c (cp_parser_primary_expression): If we found something
	that is not allowed at this point, just say so.
testsuite/
	* g++.dg/gomp/pr36475.C: New.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: fix-pr36475.diff --]
[-- Type: text/x-diff; name=fix-pr36475.diff, Size: 2186 bytes --]

Index: gcc/testsuite/g++.dg/gomp/pr36475.C
===================================================================
--- gcc/testsuite/g++.dg/gomp/pr36475.C	(revision 0)
+++ gcc/testsuite/g++.dg/gomp/pr36475.C	(revision 0)
@@ -0,0 +1,9 @@
+// PR c++/36475
+// { dg-do compile }
+// { dg-options "-fopenmp" }
+int main() {
+#pragma omp parallel for
+  for (register int i = 0; i < 2; ++i) { // { dg-error ".register. is not allowed" }
+  }
+  return 0;
+}
Index: gcc/cp/parser.c
===================================================================
--- gcc/cp/parser.c	(revision 141361)
+++ gcc/cp/parser.c	(working copy)
@@ -3372,10 +3372,21 @@ cp_parser_primary_expression (cp_parser 
 	case RID_AT_ENCODE:
 	case RID_AT_PROTOCOL:
 	case RID_AT_SELECTOR:
 	  return cp_parser_objc_expression (parser);
 
+	case RID_REGISTER:
+	case RID_STATIC:
+	case RID_EXTERN:
+	case RID_MUTABLE:
+	  if (!cp_parser_uncommitted_to_tentative_parse_p (parser))
+	    error ("%H%qE is not allowed here", 
+		   &token->location, token->u.value);
+	  cp_parser_simulate_error (parser);
+	  cp_lexer_consume_token (parser->lexer);
+	  return error_mark_node;
+
 	default:
 	  cp_parser_error (parser, "expected primary-expression");
 	  return error_mark_node;
 	}
 
@@ -10873,10 +10884,12 @@ cp_parser_type_specifier (cp_parser* par
   if (declares_class_or_enum)
     *declares_class_or_enum = 0;
   /* And that it does not specify a cv-qualifier.  */
   if (is_cv_qualifier)
     *is_cv_qualifier = false;
+
+ restart:
   /* Peek at the next token.  */
   token = cp_lexer_peek_token (parser->lexer);
 
   /* If we're looking at a keyword, we can use that to guide the
      production we choose.  */
@@ -10966,10 +10979,19 @@ cp_parser_type_specifier (cp_parser* par
     case RID_COMPLEX:
       /* The `__complex__' keyword is a GNU extension.  */
       ds = ds_complex;
       break;
 
+    case RID_REGISTER:
+    case RID_STATIC:
+    case RID_EXTERN:
+    case RID_MUTABLE:
+      error ("%H%qE is not allowed here", 
+	     &token->location, token->u.value);
+      cp_lexer_consume_token (parser->lexer);
+      goto restart;
+
     default:
       break;
     }
 
   /* Handle simple keywords.  */

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: PR c++/36475 [gomp] register keyword in openmp handled for-loop   fails
  2008-10-26 19:26 PR c++/36475 [gomp] register keyword in openmp handled for-loop fails Manuel López-Ibáñez
@ 2009-05-03 16:53 ` Manuel López-Ibáñez
  2009-05-03 21:33   ` Mark Mitchell
  0 siblings, 1 reply; 3+ messages in thread
From: Manuel López-Ibáñez @ 2009-05-03 16:53 UTC (permalink / raw)
  To: Gcc Patch List
  Cc: Mark Mitchell, Nathan Sidwell, Jason Merrill, Jakub Jelinek

[-- Attachment #1: Type: text/plain, Size: 1160 bytes --]

Updated & Bootstrapped and regression tested on
x86_64-unknown-linux-gnu with --enable-languages=all,obj-c++
--enable-decimal-float.

OK for trunk?


2008-10-26  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	PR c++/36475
cp/
	* parser.c (cp_parser_type_specifier): If we found something
	that is not allowed at this point, just say so.
testsuite/
	* g++.dg/gomp/pr36475.C: New.


2008/10/26 Manuel López-Ibáñez <lopezibanez@gmail.com>:
> If you can imagine testcases where this approach may produce worse
> results than the current code, please let me know. Notice that the new
> cases should only affect invalid code. For valid code I think the
> results should be the same as jumping directly to default.
>
> Bootstrapped and regression tested on x86_64-unknown-linux-gnu with
> --enable-languages=all,obj-c++ --enable-decimal-float.
>
> OK for trunk?
>
> 2008-10-26  Manuel López-Ibáñez  <manu@gcc.gnu.org>
>
>        PR c++/pr36475
> cp/
>        * parser.c (cp_parser_primary_expression): If we found something
>        that is not allowed at this point, just say so.
> testsuite/
>        * g++.dg/gomp/pr36475.C: New.
>

[-- Attachment #2: fix-pr36475.diff --]
[-- Type: text/plain, Size: 1554 bytes --]

Index: gcc/testsuite/g++.dg/gomp/pr36475.C
===================================================================
--- gcc/testsuite/g++.dg/gomp/pr36475.C	(revision 0)
+++ gcc/testsuite/g++.dg/gomp/pr36475.C	(revision 0)
@@ -0,0 +1,9 @@
+// PR c++/35158
+// { dg-do compile }
+// { dg-options "-fopenmp" }
+int main() {
+#pragma omp parallel for
+  for (register int i = 0; i < 2; ++i) { // { dg-error ".register. is not allowed" }
+  }
+  return 0;
+}
Index: gcc/cp/parser.c
===================================================================
--- gcc/cp/parser.c	(revision 147033)
+++ gcc/cp/parser.c	(working copy)
@@ -10981,10 +10981,12 @@ cp_parser_type_specifier (cp_parser* par
   if (declares_class_or_enum)
     *declares_class_or_enum = 0;
   /* And that it does not specify a cv-qualifier.  */
   if (is_cv_qualifier)
     *is_cv_qualifier = false;
+
+ restart:
   /* Peek at the next token.  */
   token = cp_lexer_peek_token (parser->lexer);
 
   /* If we're looking at a keyword, we can use that to guide the
      production we choose.  */
@@ -11075,10 +11077,19 @@ cp_parser_type_specifier (cp_parser* par
     case RID_COMPLEX:
       /* The `__complex__' keyword is a GNU extension.  */
       ds = ds_complex;
       break;
 
+    case RID_REGISTER:
+    case RID_STATIC:
+    case RID_EXTERN:
+    case RID_MUTABLE:
+      error_at (token->location, "%qE is not allowed here", 
+		token->u.value);
+      cp_lexer_consume_token (parser->lexer);
+      goto restart;
+
     default:
       break;
     }
 
   /* Handle simple keywords.  */

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: PR c++/36475 [gomp] register keyword in openmp handled for-loop   fails
  2009-05-03 16:53 ` Manuel López-Ibáñez
@ 2009-05-03 21:33   ` Mark Mitchell
  0 siblings, 0 replies; 3+ messages in thread
From: Mark Mitchell @ 2009-05-03 21:33 UTC (permalink / raw)
  To: Manuel López-Ibáñez
  Cc: Gcc Patch List, Nathan Sidwell, Jason Merrill, Jakub Jelinek

Manuel López-Ibáñez wrote:

> 2008-10-26  Manuel López-Ibáñez  <manu@gcc.gnu.org>
> 
> 	PR c++/36475
> cp/
> 	* parser.c (cp_parser_type_specifier): If we found something
> 	that is not allowed at this point, just say so.
> testsuite/
> 	* g++.dg/gomp/pr36475.C: New.

This makes the assumption that we are not parsing tentatively --
diagnostics can generally only be issued when not parsing tentatively.
I doubt that this is true in this case.  I suspect that either you
should be doing something in cp_parser_omp_for_loop to issue these errors.

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-05-03 21:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-26 19:26 PR c++/36475 [gomp] register keyword in openmp handled for-loop fails Manuel López-Ibáñez
2009-05-03 16:53 ` Manuel López-Ibáñez
2009-05-03 21:33   ` Mark Mitchell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).