llvm-project/clang/test/Modules/export-in-non-modules.cpp
Chuanqi Xu 4f8916cfdd [C++20] [Modules] Exit early if export decl is not valid
This patch fixes a crash due to following simple program:
> export struct Unit {
>    bool operator<(const Unit&);
> };

It would crash since the compiler would set the module ownership for
Unit. And the declaration with a module ownership is assumed to own a
module. But here isn't one. So here is the crash.

This patch fixes this by exiting early if it finds the export decl is
already invalid.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D117093
2022-01-14 10:21:42 +08:00

5 lines
229 B
C++

// RUN: %clang_cc1 -std=c++20 %s -fsyntax-only -verify
export struct Unit { // expected-error {{export declaration can only be used within a module interface unit after the module declaration}}
bool operator<(const Unit &);
};