xref: /llvm-project/clang/test/Modules/pr62359.cppm (revision 99de065b850b6e1c5461325998a40c6925d7ee9e)
1// RUN: rm -rf %t
2// RUN: mkdir -p %t
3// RUN: split-file %s %t
4//
5// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/Hello.cppm -o %t/Hello.pcm
6// RUN: not %clang_cc1 -std=c++20 -fopenmp %t/use.cpp -fmodule-file=hello=%t/Hello.pcm -fsyntax-only \
7// RUN:     2>&1 | FileCheck %t/use.cpp
8// RUN: not %clang_cc1 -std=c++20 -fopenmp %t/use2.cpp -fmodule-file=hello=%t/Hello.pcm -fsyntax-only \
9// RUN:     2>&1 | FileCheck %t/use2.cpp
10//
11// RUN: %clang_cc1 -std=c++20 -fopenmp -emit-module-interface %t/Hello.cppm -o %t/Hello.pcm
12// RUN: %clang_cc1 -std=c++20 -fopenmp %t/use.cpp -fmodule-file=hello=%t/Hello.pcm -fsyntax-only -verify
13// RUN: %clang_cc1 -std=c++20 -fopenmp %t/use2.cpp -fmodule-file=hello=%t/Hello.pcm -fsyntax-only -verify
14
15// Test again with reduced BMI
16// RUN: rm -rf %t
17// RUN: mkdir -p %t
18// RUN: split-file %s %t
19//
20// RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/Hello.cppm -o %t/Hello.pcm
21// RUN: not %clang_cc1 -std=c++20 -fopenmp %t/use.cpp -fmodule-file=hello=%t/Hello.pcm -fsyntax-only \
22// RUN:     2>&1 | FileCheck %t/use.cpp
23// RUN: not %clang_cc1 -std=c++20 -fopenmp %t/use2.cpp -fmodule-file=hello=%t/Hello.pcm -fsyntax-only \
24// RUN:     2>&1 | FileCheck %t/use2.cpp
25//
26// RUN: %clang_cc1 -std=c++20 -fopenmp -emit-reduced-module-interface %t/Hello.cppm -o %t/Hello.pcm
27// RUN: %clang_cc1 -std=c++20 -fopenmp %t/use.cpp -fmodule-file=hello=%t/Hello.pcm -fsyntax-only -verify
28// RUN: %clang_cc1 -std=c++20 -fopenmp %t/use2.cpp -fmodule-file=hello=%t/Hello.pcm -fsyntax-only -verify
29
30
31//--- Hello.cppm
32export module hello;
33export void hello() {
34
35}
36
37//--- use.cpp
38// expected-no-diagnostics
39import hello;
40int use() {
41  for(int i=0;i<10;i++)
42    hello();
43  return 0;
44}
45
46// CHECK: OpenMP{{.*}}differs in AST file '{{.*}}Hello.pcm' vs. current file
47
48//--- use2.cpp
49// expected-no-diagnostics
50import hello;
51int use2() {
52#pragma omp parallel for
53  for(int i=0;i<10;i++)
54    hello();
55  return 0;
56}
57
58// CHECK: OpenMP{{.*}}differs in AST file '{{.*}}Hello.pcm' vs. current file
59// CHECK: use of undeclared identifier 'pragma'
60