Hi,

this a second take, fixing the problem the way preferred by Jason in the audit trail. Tested x86_64-linux.

Thanks,
Paolo.

////////////////////////
/cp
2015-02-13  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/60211
        * parser.c (cp_parser_pragma): Diagnose PRAGMA_IVDEP at
        pragma_external context.

/testsuite
2015-02-13  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/60211
        * g++.dg/parse/ivdep-2.C: New.
        * g++.dg/parse/ivdep-3.C: Likewise.
Index: cp/parser.c
===================================================================
--- cp/parser.c (revision 220684)
+++ cp/parser.c (working copy)
@@ -33060,6 +33060,12 @@ cp_parser_pragma (cp_parser *parser, enum pragma_c
 
     case PRAGMA_IVDEP:
       {
+       if (context == pragma_external)
+         {
+           error_at (pragma_tok->location,
+                     "%<#pragma GCC ivdep%> must be inside a function");
+           break;
+         }
        cp_parser_skip_to_pragma_eol (parser, pragma_tok);
        cp_token *tok;
        tok = cp_lexer_peek_token (the_parser->lexer);
Index: testsuite/g++.dg/parse/ivdep-2.C
===================================================================
--- testsuite/g++.dg/parse/ivdep-2.C    (revision 0)
+++ testsuite/g++.dg/parse/ivdep-2.C    (working copy)
@@ -0,0 +1,9 @@
+// PR c++/60211
+
+void foo()
+{}
+  int i;
+#pragma GCC ivdep  // { dg-error "must be inside a function" }
+  for (i = 0; i < 2; ++i)  // { dg-error "expected|type" }
+    ;
+}  // { dg-error "expected" }
Index: testsuite/g++.dg/parse/ivdep-3.C
===================================================================
--- testsuite/g++.dg/parse/ivdep-3.C    (revision 0)
+++ testsuite/g++.dg/parse/ivdep-3.C    (working copy)
@@ -0,0 +1,8 @@
+// PR c++/60211
+
+void foo()
+{}
+#pragma GCC ivdep  // { dg-error "must be inside a function" }
+  for (int i = 0; i < 2; ++i)  // { dg-error "expected|type" }
+    ;
+}  // { dg-error "expected" }

Reply via email to