diff options
author | brooks <brooks@FreeBSD.org> | 2017-03-09 11:10:59 +0800 |
---|---|---|
committer | brooks <brooks@FreeBSD.org> | 2017-03-09 11:10:59 +0800 |
commit | 82dbb32dcfd87ae77d2a436f84d6900afded45a2 (patch) | |
tree | 165860e789c5a670389a7f09abc47e179b2e4570 /devel/llvm39 | |
parent | caee055ede7f5b389cea7240f89372c663069637 (diff) | |
download | freebsd-ports-gnome-82dbb32dcfd87ae77d2a436f84d6900afded45a2.tar.gz freebsd-ports-gnome-82dbb32dcfd87ae77d2a436f84d6900afded45a2.tar.zst freebsd-ports-gnome-82dbb32dcfd87ae77d2a436f84d6900afded45a2.zip |
Apply the changes from FreeBSD r314883:
Pull in r291403 from upstream clang trunk (by Richard Smith):
PR30305: Implement proposed DR resolution to prevent slicing via
inherited constructor.
The rule we use is that a construction of a class type T from an
argument of type U cannot use an inherited constructor if U is the
same as T or is derived from T (or if the initialization would first
convert it to such a type). This (approximately) matches the rule in
use by GCC, and matches the current proposed DR resolution.
Pull in r291955 from upstream clang trunk (by Richard Smith):
PR31606: Generalize our tentative DR resolution for inheriting
copy/move constructors to better match the pre-P0136R1 behavior.
Together, these fix an issue with C++ using declarations sometimes
enabling illegal implicit casts.
Direct commit to stable/11, since head already has clang 4.0.0, which
includes this change.
PR: 215969
Submitted by: dim
Diffstat (limited to 'devel/llvm39')
4 files changed, 90 insertions, 2 deletions
diff --git a/devel/llvm39/Makefile b/devel/llvm39/Makefile index 406342975ba1..915c4f2330cc 100644 --- a/devel/llvm39/Makefile +++ b/devel/llvm39/Makefile @@ -2,7 +2,7 @@ PORTNAME= llvm DISTVERSION= 3.9.1 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= devel lang MASTER_SITES= http://llvm.org/${PRE_}releases/${LLVM_RELEASE}/${RCDIR} PKGNAMESUFFIX= ${LLVM_SUFFIX} @@ -56,7 +56,10 @@ CLANG_EXTRA_PATCHES= \ ${PATCHDIR}/clang-patch-fopenmp.diff \ ${PATCHDIR}/clang-patch-tools_clang_lib_Headers_CMakeLists.txt \ ${PATCHDIR}/clang-patch-tools_clang_tools_clang-format_clang-format.py \ - ${PATCHDIR}/clang-patch-tools_clang_tools_scan-build_libexec_ccc-analyzer + ${PATCHDIR}/clang-patch-tools_clang_tools_scan-build_libexec_ccc-analyzer \ + ${PATCHDIR}/clang-patch-tools_clang_include_clang_Basic_DiagnosticSemaKinds.td \ + ${PATCHDIR}/clang-patch-tools_clang_lib_Sema_SemaOverload.cpp \ + ${PATCHDIR}/config-patch-tools_clang_include_clang_Sema_Overload.h CLANG_CONFLICTS_INSTALL= clang-devel-3.[1234567]* CLANG_DISTFILES= cfe-${DISTVERSION}.src${EXTRACT_SUFX} CLANG_CMAKE_ON= -DCLANG_DEFAULT_OPENMP_RUNTIME=libomp diff --git a/devel/llvm39/files/clang-patch-tools_clang_include_clang_Basic_DiagnosticSemaKinds.td b/devel/llvm39/files/clang-patch-tools_clang_include_clang_Basic_DiagnosticSemaKinds.td new file mode 100644 index 000000000000..b28f203f01e0 --- /dev/null +++ b/devel/llvm39/files/clang-patch-tools_clang_include_clang_Basic_DiagnosticSemaKinds.td @@ -0,0 +1,15 @@ + +$FreeBSD$ + +--- tools/clang/include/clang/Basic/DiagnosticSemaKinds.td.orig ++++ tools/clang/include/clang/Basic/DiagnosticSemaKinds.td +@@ -3180,6 +3180,9 @@ + + def note_ovl_candidate_inherited_constructor : Note< + "constructor from base class %0 inherited here">; ++def note_ovl_candidate_inherited_constructor_slice : Note< ++ "candidate %select{constructor|template}0 ignored: " ++ "inherited constructor cannot be used to %select{copy|move}1 object">; + def note_ovl_candidate_illegal_constructor : Note< + "candidate %select{constructor|template}0 ignored: " + "instantiation %select{takes|would take}0 its own class type by value">; diff --git a/devel/llvm39/files/clang-patch-tools_clang_lib_Sema_SemaOverload.cpp b/devel/llvm39/files/clang-patch-tools_clang_lib_Sema_SemaOverload.cpp new file mode 100644 index 000000000000..df8ef7921263 --- /dev/null +++ b/devel/llvm39/files/clang-patch-tools_clang_lib_Sema_SemaOverload.cpp @@ -0,0 +1,52 @@ + +$FreeBSD$ + +--- tools/clang/lib/Sema/SemaOverload.cpp.orig ++++ tools/clang/lib/Sema/SemaOverload.cpp +@@ -5783,6 +5783,28 @@ + Candidate.FailureKind = ovl_fail_illegal_constructor; + return; + } ++ ++ // C++ [over.match.funcs]p8: (proposed DR resolution) ++ // A constructor inherited from class type C that has a first parameter ++ // of type "reference to P" (including such a constructor instantiated ++ // from a template) is excluded from the set of candidate functions when ++ // constructing an object of type cv D if the argument list has exactly ++ // one argument and D is reference-related to P and P is reference-related ++ // to C. ++ auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl.getDecl()); ++ if (Shadow && Args.size() == 1 && Constructor->getNumParams() >= 1 && ++ Constructor->getParamDecl(0)->getType()->isReferenceType()) { ++ QualType P = Constructor->getParamDecl(0)->getType()->getPointeeType(); ++ QualType C = Context.getRecordType(Constructor->getParent()); ++ QualType D = Context.getRecordType(Shadow->getParent()); ++ SourceLocation Loc = Args.front()->getExprLoc(); ++ if ((Context.hasSameUnqualifiedType(P, C) || IsDerivedFrom(Loc, P, C)) && ++ (Context.hasSameUnqualifiedType(D, P) || IsDerivedFrom(Loc, D, P))) { ++ Candidate.Viable = false; ++ Candidate.FailureKind = ovl_fail_inhctor_slice; ++ return; ++ } ++ } + } + + unsigned NumParams = Proto->getNumParams(); +@@ -9750,6 +9772,17 @@ + case ovl_fail_enable_if: + return DiagnoseFailedEnableIfAttr(S, Cand); + ++ case ovl_fail_inhctor_slice: ++ // It's generally not interesting to note copy/move constructors here. ++ if (cast<CXXConstructorDecl>(Fn)->isCopyOrMoveConstructor()) ++ return; ++ S.Diag(Fn->getLocation(), ++ diag::note_ovl_candidate_inherited_constructor_slice) ++ << (Fn->getPrimaryTemplate() ? 1 : 0) ++ << Fn->getParamDecl(0)->getType()->isRValueReferenceType(); ++ MaybeEmitInheritedConstructorNote(S, Cand->FoundDecl); ++ return; ++ + case ovl_fail_addr_not_available: { + bool Available = checkAddressOfCandidateIsAvailable(S, Cand->Function); + (void)Available; diff --git a/devel/llvm39/files/config-patch-tools_clang_include_clang_Sema_Overload.h b/devel/llvm39/files/config-patch-tools_clang_include_clang_Sema_Overload.h new file mode 100644 index 000000000000..924e488ab22c --- /dev/null +++ b/devel/llvm39/files/config-patch-tools_clang_include_clang_Sema_Overload.h @@ -0,0 +1,18 @@ + +$FreeBSD$ + +--- tools/clang/include/clang/Sema/Overload.h.orig ++++ tools/clang/include/clang/Sema/Overload.h +@@ -586,7 +586,11 @@ + ovl_fail_enable_if, + + /// This candidate was not viable because its address could not be taken. +- ovl_fail_addr_not_available ++ ovl_fail_addr_not_available, ++ ++ /// This inherited constructor is not viable because it would slice the ++ /// argument. ++ ovl_fail_inhctor_slice, + }; + + /// OverloadCandidate - A single candidate in an overload set (C++ 13.3). |