[gomp] tests for omp master

Richard Henderson rth@redhat.com
Thu Sep 22 00:28:00 GMT 2005


Uncovered a problem with line numbers for the pragma parsing.

Creating the test directory now to, ah, make Diego conflict
with me instead of the reverse.  ;-)


r~


        * c-lex.c (c_lex_with_flags) <CPP_PRAGMA>: Set input_location.

        * testsuite/gcc.dg/gomp/gomp.exp: New.
        * testsuite/gcc.dg/gomp/master-1.c: New.
        * testsuite/gcc.dg/gomp/master-2.c: New.

Index: c-lex.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-lex.c,v
retrieving revision 1.249.4.2
diff -u -p -r1.249.4.2 c-lex.c
--- c-lex.c	28 Jul 2005 19:28:25 -0000	1.249.4.2
+++ c-lex.c	22 Sep 2005 00:21:03 -0000
@@ -453,10 +453,11 @@ c_lex_with_flags (tree *value, location_
 	  type = lex_string (tok, value, false);
 	  break;
 	}
+      *value = build_string (tok->val.str.len, (char *) tok->val.str.text);
+      break;
       
-      /* FALLTHROUGH */
-
     case CPP_PRAGMA:
+      cb_line_change (parse_in, tok, false);
       *value = build_string (tok->val.str.len, (char *) tok->val.str.text);
       break;
 
Index: testsuite/gcc.dg/gomp/gomp.exp
===================================================================
RCS file: testsuite/gcc.dg/gomp/gomp.exp
diff -N testsuite/gcc.dg/gomp/gomp.exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/gcc.dg/gomp/gomp.exp	22 Sep 2005 00:22:07 -0000
@@ -0,0 +1,20 @@
+# GCC testsuite that uses the `dg.exp' driver.
+
+# Load support procs.
+load_lib gcc-dg.exp
+
+# If a testcase doesn't have special options, use these.
+global DEFAULT_CFLAGS
+if ![info exists DEFAULT_CFLAGS] then {
+    set DEFAULT_CFLAGS " -fopenmp"
+}
+
+# Initialize `dg'.
+dg-init
+
+# Main loop.
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] \
+	"" $DEFAULT_CFLAGS
+
+# All done.
+dg-finish
Index: testsuite/gcc.dg/gomp/master-1.c
===================================================================
RCS file: testsuite/gcc.dg/gomp/master-1.c
diff -N testsuite/gcc.dg/gomp/master-1.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/gcc.dg/gomp/master-1.c	22 Sep 2005 00:22:07 -0000
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+
+extern void bar(int);
+
+void foo (void)
+{
+  #pragma omp master
+    bar(0);
+
+  #pragma omp master
+  {
+    bar(1);
+    bar(2);
+  }
+
+  /* Yes, this is legal -- structured-block contains statement contains
+     openmp-construct contains master-construct.  */
+  #pragma omp master
+  #pragma omp master
+  #pragma omp master
+    ;
+}
Index: testsuite/gcc.dg/gomp/master-2.c
===================================================================
RCS file: testsuite/gcc.dg/gomp/master-2.c
diff -N testsuite/gcc.dg/gomp/master-2.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/gcc.dg/gomp/master-2.c	22 Sep 2005 00:22:07 -0000
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+
+void f1(void)
+{
+  #pragma omp master asdf	/* { dg-error "expected new-line" } */
+}
+
+void f2(void)
+{
+  #pragma omp master
+}				/* { dg-error "expected expression" } */



More information about the Gcc-patches mailing list