From ada0888a111750ff4caec49208d11de4e29bfb61 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Wed, 19 Apr 2017 21:15:45 +0000 Subject: [PATCH] Fix assertion failure in codegen on non-template deduction guide. llvm-svn: 300762 --- clang/lib/CodeGen/CodeGenModule.cpp | 4 ++++ clang/test/CodeGenCXX/cxx1z-class-deduction.cpp | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 clang/test/CodeGenCXX/cxx1z-class-deduction.cpp diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index d84c543..1920397 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -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/clang/test/CodeGenCXX/cxx1z-class-deduction.cpp b/clang/test/CodeGenCXX/cxx1z-class-deduction.cpp new file mode 100644 index 0000000..6f8333b --- /dev/null +++ b/clang/test/CodeGenCXX/cxx1z-class-deduction.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -std=c++1z %s -emit-llvm -o - | FileCheck %s + +template struct A { + A(T = 0); + A(void*); +}; + +template A(T*) -> A; +A() -> A; + +// CHECK-LABEL: @_Z1fPi( +void f(int *p) { + // CHECK: @_ZN1AIiEC + A a{}; + + // CHECK: @_ZN1AIlEC + A b = p; + + // CHECK: @_ZN1AIxEC + A c = 123LL; +} -- 2.7.4