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
3 changes: 1 addition & 2 deletions clang/lib/Serialization/ASTWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4374,8 +4374,7 @@ class ASTDeclContextNameLookupTrait
// parent of parent. We DON'T remove the enum constant from its parent. So
// we don't need to care about merging problems here.
if (auto *ECD = dyn_cast<EnumConstantDecl>(D);
ECD && DC.isFileContext() && ECD->getOwningModule() &&
ECD->getTopLevelOwningNamedModule()->isNamedModule()) {
ECD && DC.isFileContext() && ECD->getTopLevelOwningNamedModule()) {
if (llvm::all_of(
DC.noload_lookup(
cast<EnumDecl>(ECD->getDeclContext())->getDeclName()),
Expand Down
46 changes: 46 additions & 0 deletions clang/test/Modules/crash-enum-visibility-with-header-unit.cppm
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Fixes #165445

// RUN: rm -rf %t
// RUN: mkdir -p %t
// RUN: split-file %s %t
//
// RUN: %clang_cc1 -std=c++20 -x c++-user-header %t/header.h \
// RUN: -emit-header-unit -o %t/header.pcm
//
// RUN: %clang_cc1 -std=c++20 %t/A.cppm -fmodule-file=%t/header.pcm \
// RUN: -emit-module-interface -o %t/A.pcm
//
// RUN: %clang_cc1 -std=c++20 %t/B.cppm -fmodule-file=%t/header.pcm \
// RUN: -emit-module-interface -o %t/B.pcm
//
// RUN: %clang_cc1 -std=c++20 %t/use.cpp \
// RUN: -fmodule-file=A=%t/A.pcm -fmodule-file=B=%t/B.pcm \
// RUN: -fmodule-file=%t/header.pcm \
// RUN: -verify -fsyntax-only

//--- enum.h
enum E { Value };

//--- header.h
#include "enum.h"

//--- A.cppm
module;
#include "enum.h"
export module A;

auto e = Value;

//--- B.cppm
export module B;
import "header.h";

auto e = Value;

//--- use.cpp
// expected-no-diagnostics
import A;
import B;
#include "enum.h"

auto e = Value;