Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[C++20] [Modules] Try to treat B<A> and B<NS::A> as the same type in using declarations #63595

Closed
ChuanqiXu9 opened this issue Jun 29, 2023 · 1 comment
Assignees
Labels
clang:modules C++20 modules and Clang Header Modules

Comments

@ChuanqiXu9
Copy link
Member

ChuanqiXu9 commented Jun 29, 2023

This comes from https://reviews.llvm.org/D153003 and revealed by @zygoloid.

The reproducer:

// 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.h
namespace NS {
using C = B<A>;
}
struct D : NS::C {};

//--- module1.cppm
// inside NS, using C = B<A>
module;
#include "header.h"
#include "module1.h"
export module module1;
export using ::D;

//--- module2.h
namespace NS {
using C = B<NS::A>;
}
struct D : NS::C {};

//--- module2.cppm
// inside NS, using C = B<NS::A>
module;
#include "header.h"
#include "module2.h"
export module module2;
export using ::D;

//--- merge.cpp
// expected-no-diagnostics
import module1;
import module2;
D d;

The explanation is: [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.

@ChuanqiXu9 ChuanqiXu9 added the clang:modules C++20 modules and Clang Header Modules label Jun 29, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Jun 29, 2023

@llvm/issue-subscribers-clang-modules

@ChuanqiXu9 ChuanqiXu9 self-assigned this Jul 3, 2023
razmser pushed a commit to razmser/llvm-project that referenced this issue Sep 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:modules C++20 modules and Clang Header Modules
Projects
None yet
Development

No branches or pull requests

2 participants