From: "Manuel López-Ibáñez" <lopezibanez@gmail.com>
To: "Gcc Patch List" <gcc-patches@gcc.gnu.org>
Subject: PR c++/36475 [gomp] register keyword in openmp handled for-loop fails
Date: Sun, 26 Oct 2008 19:26:00 -0000 [thread overview]
Message-ID: <6c33472e0810260531u10d7f298t1e39604a3a2320cb@mail.gmail.com> (raw)
[-- 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. */
next reply other threads:[~2008-10-26 12:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-26 19:26 Manuel López-Ibáñez [this message]
2009-05-03 16:53 ` Manuel López-Ibáñez
2009-05-03 21:33 ` Mark Mitchell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6c33472e0810260531u10d7f298t1e39604a3a2320cb@mail.gmail.com \
--to=lopezibanez@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).