[clang] [NFC][clang] Refactor CXX/module/module.interface/p1.cpp with split-file (PR #148861)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 15 07:58:27 PDT 2025
https://github.com/yronglin created https://github.com/llvm/llvm-project/pull/148861
Refine CXX/module/module.interface/p1.cpp with split-file.
This MR is a part of https://github.com/llvm/llvm-project/pull/107168.
>From 6106b92941fb39d2c93776b71738d3bbd3eb6716 Mon Sep 17 00:00:00 2001
From: yronglin <yronglin777 at gmail.com>
Date: Tue, 15 Jul 2025 22:55:41 +0800
Subject: [PATCH] [NFC][clang] Refactor CXX/module/module.interface/p1.cpp with
split-file
Signed-off-by: yronglin <yronglin777 at gmail.com>
---
clang/test/CXX/module/module.interface/p1.cpp | 42 +++++++++++--------
1 file changed, 24 insertions(+), 18 deletions(-)
diff --git a/clang/test/CXX/module/module.interface/p1.cpp b/clang/test/CXX/module/module.interface/p1.cpp
index 54a201e502323..c3bfca930f5cc 100644
--- a/clang/test/CXX/module/module.interface/p1.cpp
+++ b/clang/test/CXX/module/module.interface/p1.cpp
@@ -1,28 +1,19 @@
-// RUN: %clang_cc1 -std=c++2a %s -DERRORS -verify
-// RUN: %clang_cc1 -std=c++2a %s -emit-module-interface -o %t.pcm
-// RUN: %clang_cc1 -std=c++2a %s -fmodule-file=M=%t.pcm -DIMPLEMENTATION -verify -Db=b2 -Dc=c2
+// RUN: rm -rf %t
+// RUN: split-file %s %t
-module;
+// RUN: %clang_cc1 -std=c++2a %t/errors.cpp -verify
+// RUN: %clang_cc1 -std=c++2a %t/M.cppm -emit-module-interface -o %t/M.pcm
+// RUN: %clang_cc1 -std=c++2a %t/impl.cpp -fmodule-file=M=%t/M.pcm -verify
-#ifdef ERRORS
+//--- errors.cpp
+module;
export int a; // expected-error {{export declaration can only be used within a module purview}}
-#endif
-
-#ifndef IMPLEMENTATION
-export
-#else
-// expected-error@#1 {{export declaration can only be used within a module purview}}
-// expected-error@#2 {{export declaration can only be used within a module purview}}
-// expected-note at +2 1+{{add 'export'}}
-#endif
-module M;
-
+export module M;
export int b; // #1
namespace N {
export int c; // #2
}
-#ifdef ERRORS
namespace { // expected-note 2{{anonymous namespace begins here}}
export int d1; // expected-error {{export declaration appears within anonymous namespace}}
namespace X {
@@ -35,4 +26,19 @@ export { export int f; } // expected-error {{within another export declaration}}
module :private; // expected-note {{private module fragment begins here}}
export int priv; // expected-error {{export declaration cannot be used in a private module fragment}}
-#endif
+
+//--- M.cppm
+export module M;
+export int b;
+namespace N {
+ export int c;
+}
+
+//--- impl.cpp
+module M; // #M
+
+export int b2; // expected-error {{export declaration can only be used within a module purview}}
+namespace N {
+ export int c2; // expected-error {{export declaration can only be used within a module purview}}
+}
+// expected-note@#M 2+{{add 'export'}}
More information about the cfe-commits
mailing list