forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[C++20][Modules] Do not allow non-inline external definitions in head…
…er 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
- Loading branch information
Showing
6 changed files
with
59 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// 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}} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters