]> granicus.if.org Git - clang/commitdiff
Fix assertion failure in codegen on non-template deduction guide.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 19 Apr 2017 21:15:45 +0000 (21:15 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 19 Apr 2017 21:15:45 +0000 (21:15 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@300762 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CodeGenModule.cpp
test/CodeGenCXX/cxx1z-class-deduction.cpp [new file with mode: 0644]

index d84c543deea9b94926498f529b14827af06d71b2..19203973ff1b073ce59be343382fa7f545eca21d 100644 (file)
@@ -3794,6 +3794,10 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) {
     AddDeferredUnusedCoverageMapping(D);
     break;
 
+  case Decl::CXXDeductionGuide:
+    // Function-like, but does not result in code emission.
+    break;
+
   case Decl::Var:
   case Decl::Decomposition:
     // Skip variable templates
diff --git a/test/CodeGenCXX/cxx1z-class-deduction.cpp b/test/CodeGenCXX/cxx1z-class-deduction.cpp
new file mode 100644 (file)
index 0000000..6f8333b
--- /dev/null
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -std=c++1z %s -emit-llvm -o - | FileCheck %s
+
+template<typename T> struct A {
+  A(T = 0);
+  A(void*);
+};
+
+template<typename T> A(T*) -> A<long>;
+A() -> A<int>;
+
+// CHECK-LABEL: @_Z1fPi(
+void f(int *p) {
+  // CHECK: @_ZN1AIiEC
+  A a{};
+
+  // CHECK: @_ZN1AIlEC
+  A b = p;
+
+  // CHECK: @_ZN1AIxEC
+  A c = 123LL;
+}