From: Gauthier Harnisch Date: Sun, 22 Sep 2019 21:59:10 +0000 (+0000) Subject: [clang] fixing conditional explicit for out-of-line definition PR42980 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c60de9debdf43be97665726bd9e58a8284df541a;p=clang [clang] fixing conditional explicit for out-of-line definition PR42980 Summary: not every read in CXXConstructorDecl::getExplicitSpecifierInternal() was made on the canonical declaration. Reviewers: rsmith, aaron.ballman Reviewed By: rsmith Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67889 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@372530 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h index 49a0e6e982..a5dc83735f 100644 --- a/include/clang/AST/DeclCXX.h +++ b/include/clang/AST/DeclCXX.h @@ -2555,9 +2555,9 @@ class CXXConstructorDecl final ExplicitSpecifier getExplicitSpecifierInternal() const { if (CXXConstructorDeclBits.HasTrailingExplicitSpecifier) - return *getCanonicalDecl()->getTrailingObjects(); + return *getTrailingObjects(); return ExplicitSpecifier( - nullptr, getCanonicalDecl()->CXXConstructorDeclBits.IsSimpleExplicit + nullptr, CXXConstructorDeclBits.IsSimpleExplicit ? ExplicitSpecKind::ResolvedTrue : ExplicitSpecKind::ResolvedFalse); } @@ -2598,10 +2598,10 @@ public: InheritedConstructor Inherited = InheritedConstructor()); ExplicitSpecifier getExplicitSpecifier() { - return getExplicitSpecifierInternal(); + return getCanonicalDecl()->getExplicitSpecifierInternal(); } const ExplicitSpecifier getExplicitSpecifier() const { - return getExplicitSpecifierInternal(); + return getCanonicalDecl()->getExplicitSpecifierInternal(); } /// Return true if the declartion is already resolved to be explicit. diff --git a/test/SemaCXX/cxx2a-explicit-bool.cpp b/test/SemaCXX/cxx2a-explicit-bool.cpp index 1c532cfb59..56fa76f0a8 100644 --- a/test/SemaCXX/cxx2a-explicit-bool.cpp +++ b/test/SemaCXX/cxx2a-explicit-bool.cpp @@ -717,3 +717,21 @@ A d2{0, 0}; A d3 = {0.0, 0.0};// expected-error {{explicit deduction guide}} } + +namespace PR42980 { +using size_t = decltype(sizeof(0)); + +struct Str {// expected-note+ {{candidate constructor}} + template + explicit(N > 7)// expected-note {{resolved to true}} + Str(char const (&str)[N]); +}; + +template +Str::Str(char const(&str)[N]) { } +// expected-note@-1 {{candidate constructor}} + +Str a = "short"; +Str b = "not so short";// expected-error {{no viable conversion}} + +} \ No newline at end of file