Fixes https://github.com/llvm/llvm-project/issues/207066. `UsingEnumDecl` (representing C++20 `using enum` declarations) was not handled in `ASTContext::isSameEntity`. Consequently, identical class definitions containing a `using enum` statement failed to merge, resulting in spurious ODR mismatch errors such as: `error: 'MyStruct::MyEnum' from module 'ModuleB' is not present in definition of 'MyStruct' in module 'ModuleA'`. This patch implements merging support for `UsingEnumDecl` in `ASTContext::isSameEntity` by comparing the nested-name-specifier qualifiers and the underlying `EnumDecl` target. --------- Co-authored-by: ipopov <ipopov@google.com>
54 lines
1.0 KiB
C++
54 lines
1.0 KiB
C++
// RUN: rm -rf %t
|
|
// RUN: mkdir -p %t
|
|
// RUN: split-file %s %t
|
|
// RUN: cd %t
|
|
//
|
|
// RUN: %clang_cc1 -std=c++20 -fmodules -fimplicit-module-maps -x c++ -I%t \
|
|
// RUN: -emit-module -fmodule-name=ModuleA -o %t/ModuleA.pcm \
|
|
// RUN: %t/module.modulemap
|
|
//
|
|
// RUN: %clang_cc1 -std=c++20 -fmodules -fimplicit-module-maps -x c++ -I%t \
|
|
// RUN: -emit-module -fmodule-name=ModuleB -o %t/ModuleB.pcm \
|
|
// RUN: %t/module.modulemap
|
|
//
|
|
// RUN: %clang_cc1 -std=c++20 -fmodules -fimplicit-module-maps -x c++ -I%t \
|
|
// RUN: -fmodule-file=%t/ModuleA.pcm \
|
|
// RUN: -fmodule-file=%t/ModuleB.pcm \
|
|
// RUN: -verify %t/main.cpp
|
|
|
|
//--- common.h
|
|
#pragma once
|
|
struct MyStruct {
|
|
enum class MyEnum { A };
|
|
using enum MyEnum;
|
|
};
|
|
|
|
//--- a.h
|
|
#pragma once
|
|
#include "common.h"
|
|
|
|
//--- b.h
|
|
#pragma once
|
|
#include "common.h"
|
|
|
|
//--- module.modulemap
|
|
module ModuleA {
|
|
header "a.h"
|
|
export *
|
|
}
|
|
|
|
module ModuleB {
|
|
header "b.h"
|
|
export *
|
|
}
|
|
|
|
//--- main.cpp
|
|
#include "a.h"
|
|
#include "b.h"
|
|
|
|
inline void use() {
|
|
auto x = MyStruct::A;
|
|
}
|
|
|
|
// expected-no-diagnostics
|