Tyker created this revision. Tyker added reviewers: rsmith, aaron.ballman. Herald added a project: clang. Herald added a subscriber: cfe-commits.
not every read in CXXConstructorDecl::getExplicitSpecifierInternal() was made on the canonical declaration. Repository: rC Clang https://reviews.llvm.org/D67889 Files: clang/include/clang/AST/DeclCXX.h clang/test/SemaCXX/cxx2a-explicit-bool.cpp Index: clang/test/SemaCXX/cxx2a-explicit-bool.cpp =================================================================== --- clang/test/SemaCXX/cxx2a-explicit-bool.cpp +++ clang/test/SemaCXX/cxx2a-explicit-bool.cpp @@ -717,3 +717,21 @@ 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 <size_t N> + explicit(N > 7)// expected-note {{resolved to true}} + Str(char const (&str)[N]); +}; + +template <size_t N> +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 Index: clang/include/clang/AST/DeclCXX.h =================================================================== --- clang/include/clang/AST/DeclCXX.h +++ clang/include/clang/AST/DeclCXX.h @@ -2555,9 +2555,9 @@ ExplicitSpecifier getExplicitSpecifierInternal() const { if (CXXConstructorDeclBits.HasTrailingExplicitSpecifier) - return *getCanonicalDecl()->getTrailingObjects<ExplicitSpecifier>(); + return *getTrailingObjects<ExplicitSpecifier>(); return ExplicitSpecifier( - nullptr, getCanonicalDecl()->CXXConstructorDeclBits.IsSimpleExplicit + nullptr, CXXConstructorDeclBits.IsSimpleExplicit ? ExplicitSpecKind::ResolvedTrue : ExplicitSpecKind::ResolvedFalse); } @@ -2598,10 +2598,10 @@ 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.
Index: clang/test/SemaCXX/cxx2a-explicit-bool.cpp =================================================================== --- clang/test/SemaCXX/cxx2a-explicit-bool.cpp +++ clang/test/SemaCXX/cxx2a-explicit-bool.cpp @@ -717,3 +717,21 @@ 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 <size_t N> + explicit(N > 7)// expected-note {{resolved to true}} + Str(char const (&str)[N]); +}; + +template <size_t N> +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 Index: clang/include/clang/AST/DeclCXX.h =================================================================== --- clang/include/clang/AST/DeclCXX.h +++ clang/include/clang/AST/DeclCXX.h @@ -2555,9 +2555,9 @@ ExplicitSpecifier getExplicitSpecifierInternal() const { if (CXXConstructorDeclBits.HasTrailingExplicitSpecifier) - return *getCanonicalDecl()->getTrailingObjects<ExplicitSpecifier>(); + return *getTrailingObjects<ExplicitSpecifier>(); return ExplicitSpecifier( - nullptr, getCanonicalDecl()->CXXConstructorDeclBits.IsSimpleExplicit + nullptr, CXXConstructorDeclBits.IsSimpleExplicit ? ExplicitSpecKind::ResolvedTrue : ExplicitSpecKind::ResolvedFalse); } @@ -2598,10 +2598,10 @@ 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.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits