[clang] [OpenMP] Allow OMP6.0 features. (PR #122108)

Michael Kruse via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 27 05:56:13 PST 2025


================
@@ -205,77 +262,134 @@ namespace {
 }
 #pragma omp end declare target
 
-#pragma omp declare target link(S) // expected-error {{'S' used in declare target directive is not a variable or a function name}}
+// expected-error at +1 {{'S' used in declare target directive is not a variable or a function name}}
+#pragma omp declare target link(S) 
 
-#pragma omp declare target (x, x) // expected-error {{'x' appears multiple times in clauses on the same declare target directive}}
-#pragma omp declare target to(x) to(x) // omp45-error {{'x' appears multiple times in clauses on the same declare target directive}} omp5-error {{'x' appears multiple times in clauses on the same declare target directive}} omp51-error {{'x' appears multiple times in clauses on the same declare target directive}} omp52-error {{unexpected 'to' clause, use 'enter' instead}} omp52-error {{expected at least one 'enter', 'link' or 'indirect' clause}}
-#pragma omp declare target link(x) // expected-error {{'x' must not appear in both clauses 'to' and 'link'}}
+// expected-error at +1 {{'x' appears multiple times in clauses on the same declare target directive}}
+#pragma omp declare target (x, x) 
+// omp52-error at +3 {{unexpected 'to' clause, use 'enter' instead}}
+// omp52-error at +2 {{expected at least one 'enter', 'link' or 'indirect' clause}}
+// omp45-to-51-clause-error at +1 {{'x' appears multiple times in clauses on the same declare target directive}}
+#pragma omp declare target to(x) to(x)
+// expected-error at +1 {{'x' must not appear in both clauses 'to' and 'link'}}
+#pragma omp declare target link(x) 
 
 void bazz() {}
-#pragma omp declare target to(bazz) device_type(nohost) // omp45-error {{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}} host5-note 3{{marked as 'device_type(nohost)' here}} omp52-error {{unexpected 'to' clause, use 'enter' instead}} omp52-error {{expected at least one 'enter', 'link' or 'indirect' clause}}
+// omp52-error at +4 {{unexpected 'to' clause, use 'enter' instead}}
+// omp52-error at +3 {{expected at least one 'enter', 'link' or 'indirect' clause}}
+// host5-note at +2 3 {{marked as 'device_type(nohost)' here}}
+// omp45-error at +1 {{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}} 
+#pragma omp declare target to(bazz) device_type(nohost)
 void bazzz() {bazz();}
-#pragma omp declare target to(bazzz) device_type(nohost) // omp45-error {{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}} omp52-error {{unexpected 'to' clause, use 'enter' instead}} omp52-error {{expected at least one 'enter', 'link' or 'indirect' clause}}
-void any() {bazz();} // host5-error {{function with 'device_type(nohost)' is not available on host}}
-void host1() {bazz();} // host5-error {{function with 'device_type(nohost)' is not available on host}}
-#pragma omp declare target to(host1) device_type(host) // omp45-error {{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}} dev5-note 3 {{marked as 'device_type(host)' here}} omp52-error {{unexpected 'to' clause, use 'enter' instead}} omp52-error {{expected at least one 'enter', 'link' or 'indirect' clause}}
-void host2() {bazz();} //host5-error {{function with 'device_type(nohost)' is not available on host}}
-#pragma omp declare target to(host2) // omp52-error {{unexpected 'to' clause, use 'enter' instead}} omp52-error {{expected at least one 'enter', 'link' or 'indirect' clause}}
-void device() {host1();} // dev5-error {{function with 'device_type(host)' is not available on device}}
-#pragma omp declare target to(device) device_type(nohost) // omp45-error {{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}} host5-note 2 {{marked as 'device_type(nohost)' here}} omp52-error {{unexpected 'to' clause, use 'enter' instead}} omp52-error {{expected at least one 'enter', 'link' or 'indirect' clause}}
+// omp52-error at +3 {{unexpected 'to' clause, use 'enter' instead}}
+// omp52-error at +2 {{expected at least one 'enter', 'link' or 'indirect' clause}}
+// omp45-error at +1 {{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}}
+#pragma omp declare target to(bazzz) device_type(nohost) 
+// host5-error at +1 {{function with 'device_type(nohost)' is not available on host}}
+void any() {bazz();} 
+// host5-error at +1 {{function with 'device_type(nohost)' is not available on host}}
+void host1() {bazz();}
+// omp52-error at +4 {{unexpected 'to' clause, use 'enter' instead}}
+// omp52-error at +3 {{expected at least one 'enter', 'link' or 'indirect' clause}}
+// dev5-note at +2 3 {{marked as 'device_type(host)' here}}
+// omp45-error at +1 {{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}}
+#pragma omp declare target to(host1) device_type(host)
+//host5-error at +1 {{function with 'device_type(nohost)' is not available on host}}
+void host2() {bazz();}
+// omp52-error at +2 {{unexpected 'to' clause, use 'enter' instead}}
+// omp52-error at +1 {{expected at least one 'enter', 'link' or 'indirect' clause}}
+#pragma omp declare target to(host2) 
+// dev5-error at +1 {{function with 'device_type(host)' is not available on device}}
+void device() {host1();}
+// omp52-error at +4 {{unexpected 'to' clause, use 'enter' instead}}
+// omp52-error at +3 {{expected at least one 'enter', 'link' or 'indirect' clause}}
+// host5-note at +2 2 {{marked as 'device_type(nohost)' here}} 
+// omp45-error at +1 {{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}}
+#pragma omp declare target to(device) device_type(nohost)
 void host3() {host1();} // dev5-error {{function with 'device_type(host)' is not available on device}}
-#pragma omp declare target to(host3) // omp52-error {{unexpected 'to' clause, use 'enter' instead}} omp52-error {{expected at least one 'enter', 'link' or 'indirect' clause}}
+// omp52-error at +2 {{unexpected 'to' clause, use 'enter' instead}}
+// omp52-error at +1 {{expected at least one 'enter', 'link' or 'indirect' clause}}
+#pragma omp declare target to(host3)
 
 #pragma omp declare target
 void any1() {any();}
-void any2() {host1();} // dev5-error {{function with 'device_type(host)' is not available on device}}
-void any3() {device();} // host5-error {{function with 'device_type(nohost)' is not available on host}}
+// dev5-error at +1 {{function with 'device_type(host)' is not available on device}}
+void any2() {host1();} 
+// host5-error at +1 {{function with 'device_type(nohost)' is not available on host}}
+void any3() {device();}
 void any4() {any2();}
 #pragma omp end declare target
 
 void any5() {any();}
 void any6() {host1();}
-void any7() {device();} // host5-error {{function with 'device_type(nohost)' is not available on host}}
+// host5-error at +1 {{function with 'device_type(nohost)' is not available on host}}
+void any7() {device();}
 void any8() {any2();}
 
 int MultiDevTy;
-#pragma omp declare target to(MultiDevTy) device_type(any)    // omp45-error {{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}} omp52-error {{unexpected 'to' clause, use 'enter' instead}} omp52-error {{expected at least one 'enter', 'link' or 'indirect' clause}}
-#pragma omp declare target to(MultiDevTy) device_type(host)   // omp45-error {{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}} omp5-error {{'device_type(host)' does not match previously specified 'device_type(any)' for the same declaration}} omp51-error {{'device_type(host)' does not match previously specified 'device_type(any)' for the same declaration}} omp52-error {{unexpected 'to' clause, use 'enter' instead}} omp52-error {{expected at least one 'enter', 'link' or 'indirect' clause}}
-#pragma omp declare target to(MultiDevTy) device_type(nohost) // omp45-error {{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}} omp5-error {{'device_type(nohost)' does not match previously specified 'device_type(any)' for the same declaration}} // omp51-error {{'device_type(nohost)' does not match previously specified 'device_type(any)' for the same declaration}} omp52-error {{unexpected 'to' clause, use 'enter' instead}} omp52-error {{expected at least one 'enter', 'link' or 'indirect' clause}}
-
-static int variable = 100;  //expected-warning {{declaration is not declared in any declare target region}}
+// omp52-error at +3 {{unexpected 'to' clause, use 'enter' instead}}
+// omp52-error at +2 {{expected at least one 'enter', 'link' or 'indirect' clause}}
+// omp45-error at +1 {{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}}
+#pragma omp declare target to(MultiDevTy) device_type(any)
+// omp52-error at +4 {{unexpected 'to' clause, use 'enter' instead}}
+// omp52-error at +3 {{expected at least one 'enter', 'link' or 'indirect' clause}}
+// host-5-and-51-error at +2 {{'device_type(host)' does not match previously specified 'device_type(any)' for the same declaration}}
+// omp45-error at +1 {{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}}
+#pragma omp declare target to(MultiDevTy) device_type(host)
+// omp52-error at +4 {{unexpected 'to' clause, use 'enter' instead}}
+// omp52-error at +3 {{expected at least one 'enter', 'link' or 'indirect' clause}}
+// no-host5-and-51-error at +2 {{'device_type(nohost)' does not match previously specified 'device_type(any)' for the same declaration}}
+// omp45-error at +1 {{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}}
+#pragma omp declare target to(MultiDevTy) device_type(nohost)
+
+// expected-warning at +1 {{declaration is not declared in any declare target region}}
+static int variable = 100; 
 static float variable1 = 200;
-static float variable2 = variable1;  //expected-warning {{declaration is not declared in any declare target region}}
+// expected-warning at +1 {{declaration is not declared in any declare target region}}
+static float variable2 = variable1;  
 
-static int var = 1;  //expected-warning {{declaration is not declared in any declare target region}}
+// expected-warning at +1 {{declaration is not declared in any declare target region}}
+static int var = 1;  
 
 static int var1 = 10;
 static int *var2 = &var1;
-static int **ptr1 = &var2;  //expected-warning {{declaration is not declared in any declare target region}}
+// expected-warning at +1 {{declaration is not declared in any declare target region}}
+static int **ptr1 = &var2;  
 
 int arr[2] = {1,2};
-int (*arrptr)[2] = &arr;  //expected-warning {{declaration is not declared in any declare target region}}
+// expected-warning at +1 {{declaration is not declared in any declare target region}}
+int (*arrptr)[2] = &arr;  
 
 class declare{
   public: int x;
           void print();
 };
 declare obj1;
-declare *obj2 = &obj1;  //expected-warning {{declaration is not declared in any declare target region}}
+// expected-warning at +1 {{declaration is not declared in any declare target region}}
+declare *obj2 = &obj1;  
 
 struct target{
   int x;
   void print();
 };
-static target S;  //expected-warning {{declaration is not declared in any declare target region}}
+// expected-warning at +1 {{declaration is not declared in any declare target region}}
+static target S;  
 
 #pragma omp declare target
-int target_var = variable;  //expected-note {{used here}}
-float target_var1 = variable2;  //expected-note {{used here}}
-int *ptr = &var;  //expected-note {{used here}}
-int ***ptr2 = &ptr1;  //expected-note {{used here}}
-int (**ptr3)[2] = &arrptr;  //expected-note {{used here}}
-declare **obj3 = &obj2;  //expected-note {{used here}}
-target *S1 = &S; //expected-note {{used here}}
+// expected-note at +1 {{used here}}
----------------
Meinersbur wrote:

[not a change request] If there is just a single verify, and the line is at most 80 columns, keeping it on the same line is ok

https://github.com/llvm/llvm-project/pull/122108


More information about the cfe-commits mailing list