[PATCH] D23765: Fix for clang PR 29087

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 15 15:14:19 PDT 2016


rsmith added inline comments.

================
Comment at: lib/Sema/SemaExprCXX.cpp:4227
@@ -4226,1 +4226,3 @@
           continue;
+        // Using(Shadow)Decl itself is not a constructor
+        if (isa<UsingDecl>(ND) || isa<UsingShadowDecl>(ND))
----------------
This isn't really right: a `UsingShadowDecl` whose underlying declaration is a constructor should itself act like a constructor. This could matter in some obscure cases:

  struct B;
  struct A { A(B&); };
  struct B : A { using A::A; };

What does `__has_nothrow_copy(B)` return? It should probably be `false`, since copying a non-const `B` object will invoke the `A(B&)` constructor, which may throw, even though the `B(const B&)` constructor does not.

However, these `__has_*` traits should be considered deprecated and are essentially useless, so perhaps it doesn't matter too much whether we get these corner cases right. We also get the constructor template case "wrong" here, which I would imagine comes up a lot more frequently.

================
Comment at: test/SemaCXX/crash-has-nothrow-constructor.cpp:1
@@ +1,2 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s
+
----------------
Please add these tests into some existing test file for the type traits rather than adding two new files.


https://reviews.llvm.org/D23765





More information about the cfe-commits mailing list