brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · ccbae15 Raw
69 lines · cpp
1// Test check that consuming -E -fdirectives-only output produces the expected2// header unit.3 4// RUN: rm -rf %t5// RUN: mkdir -p %t6// RUN: split-file %s %t7// RUN: cd %t8 9// RUN: %clang_cc1 -std=c++20 -E -fdirectives-only -xc++-user-header hu-01.h \10// RUN: -o hu-01.iih11 12// RUN: %clang_cc1 -std=c++20 -emit-header-unit \13// RUN: -xc++-user-header-cpp-output hu-01.iih -o hu-01.pcm14 15// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header hu-02.h \16// RUN: -DFOO -fmodule-file=hu-01.pcm -o hu-02.pcm -Rmodule-import 2>&1 | \17// RUN: FileCheck --check-prefix=CHECK-IMP %s -DTDIR=%t18 19//--- hu-01.h20#ifndef __GUARD21#define __GUARD22 23int baz(int);24#define FORTYTWO 4225 26#define SHOULD_NOT_BE_DEFINED -127#undef SHOULD_NOT_BE_DEFINED28 29#endif // __GUARD30// expected-no-diagnostics31 32//--- hu-02.h33export import "hu-01.h";34#if !defined(FORTYTWO) || FORTYTWO != 4235#error FORTYTWO missing in hu-0236#endif37 38#ifndef __GUARD39#error __GUARD missing in hu-0240#endif41 42#ifdef SHOULD_NOT_BE_DEFINED43#error SHOULD_NOT_BE_DEFINED is visible44#endif45 46// Make sure that we have not discarded macros from the builtin file.47#ifndef __cplusplus48#error we dropped a defined macro49#endif50 51#define KAP 617452 53#ifdef FOO54#define FOO_BRANCH(X) (X) + 155inline int foo(int x) {56  if (x == FORTYTWO)57    return FOO_BRANCH(x);58  return FORTYTWO;59}60#else61#define BAR_BRANCH(X) (X) + 262inline int bar(int x) {63  if (x == FORTYTWO)64    return BAR_BRANCH(x);65  return FORTYTWO;66}67#endif68// CHECK-IMP: remark: importing module '.{{/|\\\\?}}hu-01.h' from 'hu-01.pcm'69