Iain Sandoe 335668b116 [C++20][Modules] Do not allow non-inline external definitions in header units.
[module.import/6] last sentence:
A header unit shall not contain a definition of a non-inline function or
variable whose name has external linkage.

Differential Revision: https://reviews.llvm.org/D140261
2023-01-08 12:19:23 +00:00

25 lines
595 B
C++

// RUN: mkdir -p %t
// RUN: split-file %s %t
// RUN: %clang_cc1 -std=c++20 -x c++-header %t/bad-header-unit.h \
// RUN: -emit-header-unit -o %t/bad-header-unit.pcm -verify
//--- bad-header-unit.h
inline int ok_foo () { return 0;}
static int ok_bar ();
int ok_decl ();
int bad_def () { return 2;} // expected-error {{non-inline external definitions are not permitted in C++ header units}}
inline int ok_inline_var = 1;
static int ok_static_var;
int ok_var_decl;
int bad_var_definition = 3; // expected-error {{non-inline external definitions are not permitted in C++ header units}}