111 lines · cpp
1// RUN: rm -fR %t2// RUN: split-file %s %t3// RUN: cd %t4// RUN: %clang_cc1 -verify -std=c++20 -x c++ -fmodule-map-file=modules.map -fmodule-name=foo1 -emit-module modules.map -o foo1.pcm5// RUN: %clang_cc1 -verify -std=c++20 -x c++ -fmodule-map-file=modules.map -fmodule-name=foo2 -emit-module modules.map -o foo2.pcm6// RUN: %clang_cc1 -verify -std=c++20 -x c++ -fmodule-map-file=modules.map -fmodule-file=foo1.pcm -fmodule-file=foo2.pcm server.cc7 8//--- functional9#pragma once10 11namespace std {12template <class> class function {};13} // namespace std14 15//--- foo.h16#pragma once17 18class MethodHandler {19 public:20 virtual ~MethodHandler() {}21 struct HandlerParameter {22 HandlerParameter();23 };24 virtual void RunHandler(const HandlerParameter ¶m);25};26 27template <class RequestType, class ResponseType>28class CallbackUnaryHandler : public MethodHandler {29 public:30 explicit CallbackUnaryHandler();31 32 void RunHandler(const HandlerParameter ¶m) final {33 void *call = nullptr;34 (void)[call](bool){};35 }36};37 38//--- foo1.h39// expected-no-diagnostics40#pragma once41 42#include "functional"43 44#include "foo.h"45 46class A;47 48class ClientAsyncResponseReaderHelper {49 public:50 using t = std::function<void(A)>;51 static void SetupRequest(t finish);52};53 54//--- foo2.h55// expected-no-diagnostics56#pragma once57 58#include "foo.h"59 60template <class BaseClass>61class a : public BaseClass {62 public:63 a() { [[maybe_unused]] CallbackUnaryHandler<int, int> a; }64};65 66//--- modules.map67module "foo" {68 export *69 module "foo.h" {70 export *71 textual header "foo.h"72 }73}74 75module "foo1" {76 export *77 module "foo1.h" {78 export *79 header "foo1.h"80 }81 82 use "foo"83}84 85module "foo2" {86 export *87 module "foo2.h" {88 export *89 header "foo2.h"90 }91 92 use "foo"93}94 95//--- server.cc96// expected-no-diagnostics97#include "functional"98 99#include "foo1.h"100#include "foo2.h"101 102std::function<void()> on_emit;103 104template <class RequestType, class ResponseType>105class CallbackUnaryHandler;106 107class s {};108class hs final : public a<s> {109 explicit hs() {}110};111