llvm-capstone/clang/test/Modules/cxx20-hu-03.cpp
Iain Sandoe 0687578728 [C++20][Modules][HU 2/5] Support searching Header Units in user or system search paths.
This is support for the user-facing options to create importable header units
from headers in the user or system search paths (or to be given an absolute path).

This means that an incomplete header path will be passed by the driver and the
lookup carried out using the search paths present when the front end is run.

To support this, we introduce file fypes for c++-{user,system,header-unit}-header.
These terms are the same as the ones used by GCC, to minimise the differences for
tooling (and users).

The preprocessor checks for headers before issuing a warning for
"#pragma once" in a header build.  We ensure that the importable header units
are recognised as headers in order to avoid such warnings.

Differential Revision: https://reviews.llvm.org/D121096
2022-03-26 10:17:17 +00:00

58 lines
1.1 KiB
C++

// Test check that processing headers as C++20 units allows #pragma once.
// RUN: rm -rf %t
// RUN: mkdir -p %t
// RUN: split-file %s %t
// RUN: cd %t
// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header hu-01.h \
// RUN: -Werror -o hu-01.pcm
// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header hu-02.h \
// RUN: -fmodule-file=%t/hu-01.pcm -o hu-02.pcm
// RUN: %clang_cc1 -std=c++20 -fsyntax-only imports-01.cpp \
// RUN: -fmodule-file=%t/hu-01.pcm
// RUN: %clang_cc1 -std=c++20 -fsyntax-only imports-02.cpp \
// RUN: -fmodule-file=%t/hu-02.pcm
// RUN: %clang_cc1 -std=c++20 -fsyntax-only imports-03.cpp \
// RUN: -fmodule-file=%t/hu-02.pcm
//--- hu-01.h
#pragma once
struct HU {
int a;
};
// expected-no-diagnostics
//--- hu-02.h
export import "hu-01.h";
// expected-no-diagnostics
//--- imports-01.cpp
import "hu-01.h";
HU foo(int x) {
return {x};
}
// expected-no-diagnostics
//--- imports-02.cpp
import "hu-02.h";
HU foo(int x) {
return {x};
}
// expected-no-diagnostics
//--- imports-03.cpp
import "hu-01.h";
import "hu-02.h";
HU foo(int x) {
return {x};
}
// expected-no-diagnostics