Author: yronglin Date: 2025-07-11T15:12:37+08:00 New Revision: d679b9a8226fdb1204f8022b78b761fde44fea0b
URL: https://github.com/llvm/llvm-project/commit/d679b9a8226fdb1204f8022b78b761fde44fea0b DIFF: https://github.com/llvm/llvm-project/commit/d679b9a8226fdb1204f8022b78b761fde44fea0b.diff LOG: [NFC][C++][Modules] Refine test/CXX/basic.link/p3.cpp with split-file (#147945) Refine basic.link.p3 tests with split-file. --------- Signed-off-by: Wang, Yihan <yronglin...@gmail.com> Added: Modified: clang/test/CXX/basic/basic.link/p3.cpp Removed: ################################################################################ diff --git a/clang/test/CXX/basic/basic.link/p3.cpp b/clang/test/CXX/basic/basic.link/p3.cpp index 01202264d2591..e6633a777ddef 100644 --- a/clang/test/CXX/basic/basic.link/p3.cpp +++ b/clang/test/CXX/basic/basic.link/p3.cpp @@ -1,35 +1,18 @@ -// RUN: %clang_cc1 -std=c++2a -verify %s -// RUN: %clang_cc1 -std=c++2a -verify %s -DIMPORT_ERROR=1 -// RUN: %clang_cc1 -std=c++2a -verify %s -DIMPORT_ERROR=2 +// RUN: rm -rf %t +// RUN: split-file %s %t +// RUN: %clang_cc1 -std=c++20 -verify %t/M.cpp +// RUN: %clang_cc1 -std=c++20 -verify %t/ImportError1.cpp +// RUN: %clang_cc1 -std=c++20 -verify %t/ImportError2.cpp + +//--- M.cpp module; -#if IMPORT_ERROR != 2 struct import { struct inner {}; }; -#endif struct module { struct inner {}; }; - constexpr int n = 123; export module m; // #1 - -// Import errors are fatal, so we test them in isolation. -#if IMPORT_ERROR == 1 -import x = {}; // expected-error {{expected ';' after module name}} - // expected-error@-1 {{module 'x' not found}} - -#elif IMPORT_ERROR == 2 -struct X; -template<int> struct import; -template<> struct import<n> { - static X y; -}; - -// This is not valid because the 'import <n>' is a pp-import, even though it -// grammatically can't possibly be an import declaration. -struct X {} import<n>::y; // expected-error {{'n' file not found}} - -#else module y = {}; // expected-error {{multiple module declarations}} expected-error 2{{}} // expected-note@#1 {{previous module declaration}} @@ -51,4 +34,36 @@ template<typename T> module module_var_template; // This is a variable named 'import' that shadows the type 'import' above. struct X {} import; -#endif + +//--- ImportError1.cpp +module; + +struct import { struct inner {}; }; +struct module { struct inner {}; }; + +constexpr int n = 123; + +export module m; // #1 + +import x = {}; // expected-error {{expected ';' after module name}} + // expected-error@-1 {{module 'x' not found}} + +//--- ImportError2.cpp +module; + +struct module { struct inner {}; }; + +constexpr int n = 123; + +export module m; // #1 + +struct X; +template<int> struct import; +template<> struct import<n> { + static X y; +}; + +// This is not valid because the 'import <n>' is a pp-import, even though it +// grammatically can't possibly be an import declaration. +struct X {} import<n>::y; // expected-error {{'n' file not found}} + _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits