Files
clang-p2996/clang/test/Modules/pr63595.cppm
Chuanqi Xu f82df0b285 [C++20] [Modules] Use CanonicalType for base classes
This comes from https://reviews.llvm.org/D153003

By @rsmith, the test case is valid since:

> Per [temp.type]/1.4 (http://eel.is/c++draft/temp.type#1.4),
>
>> Two template-ids are the same if [...] their corresponding template
>> template-arguments refer to the same template.
> so B<A> and B<NS::A> are the same type. The stricter "same sequence of
> tokens" rule doesn't apply here, because using-declarations are not
> definitions.

> we should either (preferably) be including only the syntactic form of
> the base specifier (because local syntax is what the ODR covers), or
> the canonical type (which should be the same for both
> using-declarations).

Here we adopt the second suggested solutions.

Reviewed By: cor3ntin, v.g.vassilev

Differential Revision: https://reviews.llvm.org/D154324
2023-07-11 15:59:03 +08:00

45 lines
863 B
C++

// RUN: rm -rf %t
// RUN: mkdir %t
// RUN: split-file %s %t
//
// RUN: %clang_cc1 -std=c++20 -emit-module-interface -I%t %t/module1.cppm -o %t/module1.pcm
// RUN: %clang_cc1 -std=c++20 -emit-module-interface -I%t %t/module2.cppm -o %t/module2.pcm
// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/merge.cpp -verify -fsyntax-only
//--- header.h
namespace NS {
template <int I>
class A {
};
template <template <int I_> class T>
class B {
};
}
//--- module1.cppm
// inside NS, using C = B<A>
module;
export module module1;
#include "header.h"
namespace NS {
using C = B<A>;
}
export struct D : NS::C {};
//--- module2.cppm
// inside NS, using C = B<NS::A>
module;
export module module2;
#include "header.h"
namespace NS {
using C = B<NS::A>;
}
export struct D : NS::C {};
//--- merge.cpp
// expected-no-diagnostics
import module1;
import module2;
D d;