Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clang/lib/CIR/CodeGen/CIRGenDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ void CIRGenFunction::emitExprAsInit(const Expr *init, const ValueDecl *d,

void CIRGenFunction::emitDecl(const Decl &d) {
switch (d.getKind()) {
case Decl::LinkageSpec:
case Decl::Namespace:
llvm_unreachable("Declaration should not be in declstmts!");

Expand Down
3 changes: 2 additions & 1 deletion clang/lib/CIR/CodeGen/CIRGenModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -677,8 +677,9 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
break;

// C++ Decls
case Decl::LinkageSpec:
case Decl::Namespace:
emitDeclContext(cast<NamespaceDecl>(decl));
emitDeclContext(Decl::castToDeclContext(decl));
break;
}
}
Expand Down
42 changes: 42 additions & 0 deletions clang/test/CIR/CodeGen/linkage-spec.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o - 2>&1 | FileCheck %s

extern "C" void TopLevelC(){}
// CHECK: cir.func @TopLevelC() {
extern "C++" void TopLevelCpp(){}
// CHECK: cir.func @_Z11TopLevelCppv() {

extern "C++" {
void ExternCppEmpty(){}
// CHECK: cir.func @_Z14ExternCppEmptyv() {
extern "C" void ExternCpp_C(){}
// CHECK: cir.func @ExternCpp_C() {
extern "C++" void ExternCpp_Cpp(){}
// CHECK: cir.func @_Z13ExternCpp_Cppv() {

extern "C" {
void ExternCpp_CEmpty(){}
// CHECK: cir.func @ExternCpp_CEmpty() {
extern "C" void ExternCpp_C_C(){}
// CHECK: cir.func @ExternCpp_C_C() {
extern "C++" void ExternCpp_C_Cpp(){}
// CHECK: cir.func @_Z15ExternCpp_C_Cppv() {
}
}

extern "C" {
void ExternCEmpty(){}
// CHECK: cir.func @ExternCEmpty() {
extern "C" void ExternC_C(){}
// CHECK: cir.func @ExternC_C() {
extern "C++" void ExternC_Cpp(){}
// CHECK: cir.func @_Z11ExternC_Cppv() {
extern "C++" {
void ExternC_CppEmpty(){}
// CHECK: cir.func @_Z16ExternC_CppEmptyv() {
extern "C" void ExternC_Cpp_C(){}
// CHECK: cir.func @ExternC_Cpp_C() {
extern "C++" void ExternC_Cpp_Cpp(){}
// CHECK: cir.func @_Z15ExternC_Cpp_Cppv() {
}
}