[PATCH] D67889: [clang] fixing conditional explicit for out-of-line definition PR42980

Tyker via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 22 15:02:45 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL372530: [clang] fixing conditional explicit for out-of-line definition PR42980 (authored by Tyker, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67889?vs=221216&id=221241#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67889/new/

https://reviews.llvm.org/D67889

Files:
  cfe/trunk/include/clang/AST/DeclCXX.h
  cfe/trunk/test/SemaCXX/cxx2a-explicit-bool.cpp


Index: cfe/trunk/include/clang/AST/DeclCXX.h
===================================================================
--- cfe/trunk/include/clang/AST/DeclCXX.h
+++ cfe/trunk/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: cfe/trunk/test/SemaCXX/cxx2a-explicit-bool.cpp
===================================================================
--- cfe/trunk/test/SemaCXX/cxx2a-explicit-bool.cpp
+++ cfe/trunk/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 at -1 {{candidate constructor}}
+
+Str a = "short";
+Str b = "not so short";// expected-error {{no viable conversion}}
+
+}
\ No newline at end of file


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67889.221241.patch
Type: text/x-patch
Size: 2032 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190922/9476cfbb/attachment.bin>


More information about the llvm-commits mailing list