Matheus Izvekov 5485c7021a
[clang] fix redecl chain assumption when checking linkage consistency (#153996)
In C++, it can be assumed the same linkage will be computed for all
redeclarations of an entity, and we have assertions to check this.

However, the linkage for a declaration can be requested in the middle of
deserealization, and at this point the redecl chain is not well formed,
as computation of the most recent declaration is deferred.

This patch makes that assertion work even in such conditions.

This fixes a regression introduced in
https://github.com/llvm/llvm-project/pull/147835, which was never
released, so there are no release notes for this.

Fixes #153933
2025-08-19 14:32:08 -03:00

24 lines
446 B
C++

// RUN: rm -rf %t
// RUN: mkdir -p %t
// RUN: split-file %s %t
//
// RUN: %clang_cc1 -std=c++20 %t/B.cppm -emit-module-interface -o %t/B.pcm
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -fprebuilt-module-path=%t %t/C.cpp
//--- A.hpp
template<class> struct A {};
template<class T> struct B {
virtual A<T> v() { return {}; }
};
B<void> x;
//--- B.cppm
module;
#include "A.hpp"
export module B;
using ::x;
//--- C.cpp
#include "A.hpp"
import B;