llvm-project/clang/test/Parser/pragma-export.cpp
Sean Perry 7638c1df0e
[SystemZ][z/OS] Implement #pragma export (#141671)
Implement the export pragma that is used in the z/OS XL C/C++ compiler
to indicate that an external symbol is to be exported from the shared
library. The syntax for the pragma is:
```
'#pragma' 'export' '(' name ')'
```
For C++ if `name` is a function it needs to be declared `extern "C"`.

See the following for the XL documentation:
- https://www.ibm.com/docs/en/zos/3.1.0?topic=descriptions-pragma-export

This code was originally in PR
https://github.com/llvm/llvm-project/pull/111035. I have split it out
into separate PRs so the code for #pragma export is in one PR and the
code for _Export keyword is in another. See that original PR for earlier
comments.
2026-01-23 14:46:31 -05:00

17 lines
622 B
C++

// RUN: %clang_cc1 -x c++ -triple s390x-ibm-zos -fsyntax-only -verify %s
extern int i;
#pragma export( // expected-warning {{expected identifier in '#pragma export' - ignored}}
#pragma export() // expected-warning {{expected identifier in '#pragma export' - ignored}}
#pragma export(i)
struct S {
static int i;
};
#pragma export(S::i) // expected-warning {{missing ')' after '#pragma export' - ignoring}}
void f(int);
void f(double, double);
#pragma export(f // expected-warning {{missing ')' after '#pragma export' - ignoring}}
#pragma export(f( // expected-warning {{missing ')' after '#pragma export' - ignoring}}