From 1b8778ca2b466953c8efc74b1d2dff11680dc3c5 Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Tue, 24 May 2016 12:10:36 +0000 Subject: [PATCH] [modules] Ask the canonical decl whether the constructor was defaulted. In case of template instantiations query the template instantiation pattern, which had actually '=default'. Fixes https://llvm.org/bugs/show_bug.cgi?id=27739 Patch reviewed by Richard Smith. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@270553 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDeclCXX.cpp | 8 ++++---- .../Modules/Inputs/PR27739/DataInputHandler.h | 19 ++++++++++++++++++ test/Modules/Inputs/PR27739/Types.h | 1 + test/Modules/Inputs/PR27739/map | 20 +++++++++++++++++++ test/Modules/Inputs/PR27739/module.modulemap | 2 ++ test/Modules/pr27739.cpp | 12 +++++++++++ 6 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 test/Modules/Inputs/PR27739/DataInputHandler.h create mode 100644 test/Modules/Inputs/PR27739/Types.h create mode 100644 test/Modules/Inputs/PR27739/map create mode 100644 test/Modules/Inputs/PR27739/module.modulemap create mode 100644 test/Modules/pr27739.cpp diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 38b4acfbdc..8212bd4db3 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -13098,14 +13098,14 @@ void Sema::SetDeclDefaulted(Decl *Dcl, SourceLocation DefaultLoc) { // the record is complete. const FunctionDecl *Primary = MD; if (const FunctionDecl *Pattern = MD->getTemplateInstantiationPattern()) - // Find the uninstantiated declaration that actually had the '= default' - // on it. - Pattern->isDefined(Primary); + // Ask the template instantiation pattern that actually had the + // '= default' on it. + Primary = Pattern; // If the method was defaulted on its first declaration, we will have // already performed the checking in CheckCompletedCXXClass. Such a // declaration doesn't trigger an implicit definition. - if (Primary == Primary->getCanonicalDecl()) + if (Primary->getCanonicalDecl()->isDefaulted()) return; CheckExplicitlyDefaultedSpecialMember(MD); diff --git a/test/Modules/Inputs/PR27739/DataInputHandler.h b/test/Modules/Inputs/PR27739/DataInputHandler.h new file mode 100644 index 0000000000..1ef02ecb8d --- /dev/null +++ b/test/Modules/Inputs/PR27739/DataInputHandler.h @@ -0,0 +1,19 @@ +template < typename > struct vector {}; + +#include +#include "Types.h" + +struct TString { + TString (char *); +}; + +struct TreeInfo {}; + +class DataInputHandler { + void AddTree (); + void SignalTreeInfo () { + fInputTrees[(char*)""]; + } + map >fInputTrees; + map fExplicitTrainTest; +}; diff --git a/test/Modules/Inputs/PR27739/Types.h b/test/Modules/Inputs/PR27739/Types.h new file mode 100644 index 0000000000..6d458a8d98 --- /dev/null +++ b/test/Modules/Inputs/PR27739/Types.h @@ -0,0 +1 @@ +#include diff --git a/test/Modules/Inputs/PR27739/map b/test/Modules/Inputs/PR27739/map new file mode 100644 index 0000000000..612685c9e5 --- /dev/null +++ b/test/Modules/Inputs/PR27739/map @@ -0,0 +1,20 @@ +#ifndef _GLIBCXX_MAP +#define _GLIBCXX_MAP +struct basic_string { + basic_string(char *); +} typedef string; + +template class D; +template struct D { + _Elements _M_; + D(D &) = default; +}; + +template D<_Elements &&> forward_as_tuple(_Elements); + +template struct map { + _Tp operator[](_Key p1) { + auto b = &forward_as_tuple(p1); + } +}; +#endif diff --git a/test/Modules/Inputs/PR27739/module.modulemap b/test/Modules/Inputs/PR27739/module.modulemap new file mode 100644 index 0000000000..d611e8079e --- /dev/null +++ b/test/Modules/Inputs/PR27739/module.modulemap @@ -0,0 +1,2 @@ +module "DataInputHandler.h" { header "DataInputHandler.h" export * } +module "Types.h" { header "Types.h" export *} diff --git a/test/Modules/pr27739.cpp b/test/Modules/pr27739.cpp new file mode 100644 index 0000000000..b27dc1b093 --- /dev/null +++ b/test/Modules/pr27739.cpp @@ -0,0 +1,12 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -std=c++11 -internal-externc-isystem %S/Inputs/PR27739 -verify %s +// RUN: %clang_cc1 -std=c++11 -fmodules -fmodule-map-file=%S/Inputs/PR27739/module.modulemap -fmodules-cache-path=%t -internal-externc-isystem %S/Inputs/PR27739/ -verify %s + +#include "DataInputHandler.h" + +void DataInputHandler::AddTree() { + fInputTrees[(char*)""]; + fExplicitTrainTest[(char*)""]; +} + +// expected-no-diagnostics -- 2.50.1