Author: erichkeane Date: 2024-02-29T08:57:42-08:00 New Revision: 2d61979137cfea8f016e618dd17f5be8e7d865bf
URL: https://github.com/llvm/llvm-project/commit/2d61979137cfea8f016e618dd17f5be8e7d865bf DIFF: https://github.com/llvm/llvm-project/commit/2d61979137cfea8f016e618dd17f5be8e7d865bf.diff LOG: [OpenACC] Add dependent test for break/continue compute construct diag I discovered while debugging something else that this could possibly cause an assert if I'm not careful with followup patches, so add the tests. Added: Modified: clang/test/SemaOpenACC/no-branch-in-out.cpp Removed: ################################################################################ diff --git a/clang/test/SemaOpenACC/no-branch-in-out.cpp b/clang/test/SemaOpenACC/no-branch-in-out.cpp index 232e372cedd357..9affdf733ace8d 100644 --- a/clang/test/SemaOpenACC/no-branch-in-out.cpp +++ b/clang/test/SemaOpenACC/no-branch-in-out.cpp @@ -15,3 +15,100 @@ void ReturnTest() { } } } + +template<typename T> +void BreakContinue() { + +#pragma acc parallel + for(int i =0; i < 5; ++i) { + switch(i) { + case 0: + break; // leaves switch, not 'for'. + default: + i +=2; + break; + } + if (i == 2) + continue; + + break; // expected-error{{invalid branch out of OpenACC Compute Construct}} + } + + int j; + switch(j) { + case 0: +#pragma acc parallel + { + break; // expected-error{{invalid branch out of OpenACC Compute Construct}} + } + case 1: +#pragma acc parallel + { + } + break; + } + +#pragma acc parallel + for(int i = 0; i < 5; ++i) { + if (i > 1) + break; // expected-error{{invalid branch out of OpenACC Compute Construct}} + } + +#pragma acc parallel + switch(j) { + case 1: + break; + } + +#pragma acc parallel + { + for(int i = 1; i < 100; i++) { + if (i > 4) + break; + } + } + + for (int i =0; i < 5; ++i) { +#pragma acc parallel + { + continue; // expected-error{{invalid branch out of OpenACC Compute Construct}} + } + } + +#pragma acc parallel + for (int i =0; i < 5; ++i) { + continue; + } + +#pragma acc parallel + for (int i =0; i < 5; ++i) { + { + continue; + } + } + + for (int i =0; i < 5; ++i) { +#pragma acc parallel + { + break; // expected-error{{invalid branch out of OpenACC Compute Construct}} + } + } + +#pragma acc parallel + while (j) { + --j; + if (j > 4) + break; // expected-error{{invalid branch out of OpenACC Compute Construct}} + } + +#pragma acc parallel + do { + --j; + if (j > 4) + break; // expected-error{{invalid branch out of OpenACC Compute Construct}} + } while (j ); +} + +void Instantiate() { + BreakContinue<int>(); +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits