r359949 - [clang] adding explicit(bool) from c++2a

Hans Wennborg via cfe-commits cfe-commits at lists.llvm.org
Mon May 6 02:49:19 PDT 2019


On Sat, May 4, 2019 at 2:06 AM Nicolas Lesser via cfe-commits
<cfe-commits at lists.llvm.org> wrote:
>
> Author: rakete1111
> Date: Fri May  3 17:09:00 2019
> New Revision: 359949
>
> URL: http://llvm.org/viewvc/llvm-project?rev=359949&view=rev
> Log:
> [clang] adding explicit(bool) from c++2a
>
> this patch adds support for the explicit bool specifier.
>
> Changes:
> - The parsing for the explicit(bool) specifier was added in ParseDecl.cpp.
> - The storage of the explicit specifier was changed. the explicit specifier was stored as a boolean value in the FunctionDeclBitfields and in the DeclSpec class. now it is stored as a PointerIntPair<Expr*, 2> with a flag and a potential expression in CXXConstructorDecl, CXXDeductionGuideDecl, CXXConversionDecl and in the DeclSpec class.
> - Following the AST change, Serialization, ASTMatchers, ASTComparator and ASTPrinter were adapted.
> - Template instantiation was adapted to instantiate the potential expressions of the explicit(bool) specifier When instantiating their associated declaration.
> - The Add*Candidate functions were adapted, they now take a Boolean indicating if the context allowing explicit constructor or conversion function and this boolean is used to remove invalid overloads that required template instantiation to be detected.
> - Test for Semantic and Serialization were added.
>
> This patch is not yet complete. I still need to check that interaction with CTAD and deduction guides is correct. and add more tests for AST operations. But I wanted first feedback.
> Perhaps this patch should be spited in smaller patches, but making each patch testable as a standalone may be tricky.
>
> Patch by Tyker
>
> Differential Revision: https://reviews.llvm.org/D60934

This broke the Chromium (and we got a separate report about V8 too)
builds, causing compile failures pretty early in the build. Here's a
reduced test case:

struct S {
  template <typename = int> explicit S();
};

struct T : S {};

struct U : T {
  U();
};
U::U() {}

$ clang -c /tmp/x.cc
/tmp/x.cc:10:4: error: call to implicitly-deleted default constructor of 'T'
U::U() {}
   ^
/tmp/x.cc:5:12: note: default constructor of 'T' is implicitly deleted
because base class 'S' has no default constructor
struct T : S {};
           ^
1 error generated.


Based on the commit message, it sounds like this change was not intentional?

I don't know if the error message actually makes sense or whether the
code should be legal. Note that de-templatizing S::S(), or making U
inherit directly from S instead of T, makes the error go away.

If it turns out the code is in fact illegal and Clang was right to
error here, it would be good if we could get some heads up to fix our
code first.

I've reverted this change in r360024 until it's cleared up whether the
new compile error is intentional.


More information about the cfe-commits mailing list