It happens from time to time that we run into asserts, esp. for OMP_CLAUSE_DECL.

The reason is that the comment for omp_clause_code implies that arguments
should be appended (misreading the "Don't reorder") and that there was
no crossref to those macros.

This patch adds comments both a generic cross ref and marking the ranges of
the various #define that use OMP_CLAUSE_RANGE_CHECK.

Comments or further suggestions before I apply it?

Tobias

PS: I think some cleanup is needed as I think both 
OMP_CLAUSE_DECL/OMP_CLAUSE_SIZE
span too many clauses, which is harmless but defeats a bit the purpose of the 
range
check.
tree-core.h (omp_clause_code): Comments regarding range checks for OMP_CLAUSE_...

gcc/ChangeLog:

	* tree-core.h (enum omp_clause_code): Add comments to cross ref to
	OMP_CLAUSE_DECL etc. and mark the ranges used in the range checks.

diff --git a/gcc/tree-core.h b/gcc/tree-core.h
index e82f3a5f4f5..b12a37c54c6 100644
--- a/gcc/tree-core.h
+++ b/gcc/tree-core.h
@@ -241,12 +241,19 @@ enum tree_code_class {
 };
 
 /* OMP_CLAUSE codes.  Do not reorder, as this is used to index into
-   the tables omp_clause_num_ops and omp_clause_code_name.  */
+   the tables omp_clause_num_ops and omp_clause_code_name.
+
+   Note additionally that there are various range checks such as
+   for OMP_CLAUSE_SIZE or OMP_CLAUSE_DECL; clauses having those shall
+   be inside that range, those that have not shall be outside.  */
+
 enum omp_clause_code {
   /* Clause zero is special-cased inside the parser
      (c_parser_omp_variable_list).  */
   OMP_CLAUSE_ERROR = 0,
 
+  /* Range START below for: OMP_CLAUSE_DECL  */
+
   /* OpenACC/OpenMP clause: private (variable_list).  */
   OMP_CLAUSE_PRIVATE,
 
@@ -259,6 +266,9 @@ enum omp_clause_code {
   /* OpenMP clause: lastprivate (variable_list).  */
   OMP_CLAUSE_LASTPRIVATE,
 
+  /* Range START below for: OMP_CLAUSE_REDUCTION_CODE and
+     OMP_CLAUSE_REDUCTION_{INIT,MERGE,{DECL_,}PLACEHOLDER,OMP_ORIG_REF}  */
+
   /* OpenACC/OpenMP clause: reduction (operator:variable_list).
      OMP_CLAUSE_REDUCTION_CODE: The tree_code of the operator.
      Operand 1: OMP_CLAUSE_REDUCTION_INIT: Stmt-list to initialize the var.
@@ -277,6 +287,9 @@ enum omp_clause_code {
   /* OpenMP clause: in_reduction (operator:variable_list).  */
   OMP_CLAUSE_IN_REDUCTION,
 
+  /* Range END above for: OMP_CLAUSE_REDUCTION_CODE  and
+     OMP_CLAUSE_REDUCTION_{INIT,MERGE,{DECL_,}PLACEHOLDER,OMP_ORIG_REF}  */
+
   /* OpenMP clause: copyin (variable_list).  */
   OMP_CLAUSE_COPYIN,
 
@@ -330,12 +343,17 @@ enum omp_clause_code {
   /* OpenMP clause: exclusive (variable-list).  */
   OMP_CLAUSE_EXCLUSIVE,
 
+  /* Range START below for: OMP_CLAUSE_SIZE  */
+  /* Range START below for: OMP_CLAUSE_MOTION_PRESENT  */
+
   /* OpenMP clause: from (variable-list).  */
   OMP_CLAUSE_FROM,
 
   /* OpenMP clause: to (variable-list).  */
   OMP_CLAUSE_TO,
 
+  /* Range END above for: OMP_CLAUSE_MOTION_PRESENT  */
+
   /* OpenACC clauses: {copy, copyin, copyout, create, delete, deviceptr,
      device, host (self), present, present_or_copy (pcopy), present_or_copyin
      (pcopyin), present_or_copyout (pcopyout), present_or_create (pcreate)}
@@ -354,6 +372,8 @@ enum omp_clause_code {
      #pragma acc cache (variable-list).  */
   OMP_CLAUSE__CACHE_,
 
+  /* Range END above for: OMP_CLAUSE_SIZE */
+
   /* OpenACC clause: gang [(gang-argument-list)].
      Where
       gang-argument-list: [gang-argument-list, ] gang-argument
@@ -386,6 +406,8 @@ enum omp_clause_code {
   /* Internal clause: temporary for inscan reductions.  */
   OMP_CLAUSE__SCANTEMP_,
 
+  /* Range END above for: OMP_CLAUSE_DECL  */
+
   /* OpenACC/OpenMP clause: if (scalar-expression).  */
   OMP_CLAUSE_IF,
 

Reply via email to