saarraz / clang-concepts-monorepo

****** OBSOLETE - CONCEPTS HAS BEEN MERGED INTO CLANG TRUNK AND DEVELOPMENT CONTINUES THERE ****** This fork of llvm-project contains my implementation of C++2a Concepts for the Clang compiler, and will be updated regularly with bug fixes until the whole feature is merged to trunk. Follow the instructions here https://clang.llvm.org/get_started.html to build, then use the flags "-std=c++2a -Xclang -fconcepts-ts" to enable concepts.
27 stars 3 forks source link

Constrained specialization of a template is rejected #15

Closed brycelelbach closed 5 years ago

brycelelbach commented 5 years ago

Ran into this trying to build @cjdb 's ranges/concepts repo with a recent build of concepts clang.

$ cat test.cpp 
#include <type_traits>

template <typename T>
concept integral = std::is_integral_v<T>;

template <class> struct foo {};

template <class T> requires integral<T> struct foo<T> {};

int main() { foo<int> f;  }
$ ~/install/cpp_toolchains/clang_llvm_concepts/bin/clang++ test.cpp -std=c++2a --version
clang version 10.0.0 (git@github.com:saarraz/clang-concepts-monorepo.git 2b7ef558dc44fa5fe8ef29d5f20eca7b40174129)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/wash/install/cpp_toolchains/clang_llvm_concepts/bin
$ ~/install/cpp_toolchains/clang_llvm_concepts/bin/clang++ test.cpp -std=c++2a
test.cpp:8:48: error: class template partial specialization does not specialize any template argument; to define the primary template, remove the template argument list
template <class T> requires integral<T> struct foo<T> {};
                                               ^  ~~~
test.cpp:8:29: error: requires clause differs in template redeclaration
template <class T> requires integral<T> struct foo<T> {};
                            ^
test.cpp:6:1: note: previous template declaration is here
template <class> struct foo {};
^
2 errors generated.

It appears this used to work with an older build of concept clang.

Is this a bug in the implementation, or is Chris' code invalid?

brycelelbach commented 5 years ago

Ah, seems to work fine with -Xclang -fconcepts-ts. So maybe just an error on my end?

saarraz commented 5 years ago

Yeah 😅