Skip to content

Commit 83ca877

Browse files
authored
[clang][bytecode] Reject final ltor casts on string literals (#156669)
Similar to what the current interpreter does.
1 parent 5eb0ec4 commit 83ca877

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

clang/lib/AST/ByteCode/EvalEmitter.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@ template <> bool EvalEmitter::emitRet<PT_Ptr>(const SourceInfo &Info) {
213213
if (!Ptr.isZero() && !Ptr.isDereferencable())
214214
return false;
215215

216+
if (Ptr.pointsToStringLiteral() && Ptr.isArrayRoot())
217+
return false;
218+
216219
if (!Ptr.isZero() && !CheckFinalLoad(S, OpPC, Ptr))
217220
return false;
218221

clang/test/AST/ByteCode/openmp.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify=expected,both -fopenmp %s
2-
// RUN: %clang_cc1 -verify=ref,both -fopenmp %s
1+
// RUN: %clang_cc1 -verify=expected,both -fopenmp -fopenmp-version=60 %s -fexperimental-new-constant-interpreter
2+
// RUN: %clang_cc1 -verify=ref,both -fopenmp -fopenmp-version=60 %s
33

44
int test1() {
55
int i;
@@ -11,3 +11,19 @@ int test1() {
1111
for (int i = 0; i < 10; ++i);
1212
}
1313

14+
extern int omp_get_thread_num(void);
15+
16+
#define N 64
17+
18+
int test2() {
19+
int x = 0;
20+
int device_result[N] = {0};
21+
22+
#pragma omp target parallel loop num_threads(strict: N) severity(warning) message("msg")
23+
for (int i = 0; i < N; i++) {
24+
x = omp_get_thread_num();
25+
device_result[i] = i + x;
26+
}
27+
}
28+
29+

0 commit comments

Comments
 (0)