aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-01-22 16:52:41 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-01-22 16:52:41 +0000
commit5df539a1004bc4db5c38b33ba3e219595a10ae3c (patch)
tree8f7162c2eeb96f9bef560b568c3a039187a31953 /lib
parentd2e0a8dd949ab874c6d66f97106bd5c270e2fa7d (diff)
downloadsrc-5df539a1004bc4db5c38b33ba3e219595a10ae3c.tar.gz
src-5df539a1004bc4db5c38b33ba3e219595a10ae3c.zip
Vendor import of clang release_40 branch r292732:vendor/clang/clang-release_40-r292732
Notes
Notes: svn path=/vendor/clang/dist/; revision=312627 svn path=/vendor/clang/clang-release_40-r292732/; revision=312628; tag=vendor/clang/clang-release_40-r292732
Diffstat (limited to 'lib')
-rw-r--r--lib/Basic/Targets.cpp2
-rw-r--r--lib/Frontend/DependencyFile.cpp4
-rw-r--r--lib/Parse/ParseExpr.cpp7
-rw-r--r--lib/Sema/SemaOverload.cpp54
-rw-r--r--lib/Sema/SemaTemplate.cpp28
5 files changed, 51 insertions, 44 deletions
diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp
index 89e3f3ebbe3f..1a95ff26816e 100644
--- a/lib/Basic/Targets.cpp
+++ b/lib/Basic/Targets.cpp
@@ -512,7 +512,7 @@ protected:
Builder.defineMacro("__unix__");
Builder.defineMacro("__ELF__");
if (Opts.POSIXThreads)
- Builder.defineMacro("_POSIX_THREADS");
+ Builder.defineMacro("_REENTRANT");
switch (Triple.getArch()) {
default:
diff --git a/lib/Frontend/DependencyFile.cpp b/lib/Frontend/DependencyFile.cpp
index 059f116a3c31..bd14c53e4d15 100644
--- a/lib/Frontend/DependencyFile.cpp
+++ b/lib/Frontend/DependencyFile.cpp
@@ -447,9 +447,9 @@ void DFGImpl::OutputDependencyFile() {
// Create phony targets if requested.
if (PhonyTarget && !Files.empty()) {
// Skip the first entry, this is always the input file itself.
- for (StringRef File : Files) {
+ for (auto I = Files.begin() + 1, E = Files.end(); I != E; ++I) {
OS << '\n';
- PrintFilename(OS, File, OutputFormat);
+ PrintFilename(OS, *I, OutputFormat);
OS << ":\n";
}
}
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp
index e7b6c6ff90b3..ee06c76f6024 100644
--- a/lib/Parse/ParseExpr.cpp
+++ b/lib/Parse/ParseExpr.cpp
@@ -1652,9 +1652,10 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
if (Tok.is(tok::code_completion)) {
// Code completion for a member access expression.
- Actions.CodeCompleteMemberReferenceExpr(
- getCurScope(), LHS.get(), OpLoc, OpKind == tok::arrow,
- ExprStatementTokLoc == LHS.get()->getLocStart());
+ if (Expr *Base = LHS.get())
+ Actions.CodeCompleteMemberReferenceExpr(
+ getCurScope(), Base, OpLoc, OpKind == tok::arrow,
+ ExprStatementTokLoc == Base->getLocStart());
cutOffParsing();
return ExprError();
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index afdae4ed6d7d..c66fe7678d8c 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -5944,6 +5944,28 @@ Sema::AddOverloadCandidate(FunctionDecl *Function,
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();
@@ -6016,31 +6038,6 @@ Sema::AddOverloadCandidate(FunctionDecl *Function,
}
}
- // C++ [over.best.ics]p4+: (proposed DR resolution)
- // If the target is the first parameter of an inherited constructor when
- // constructing an object of type C with an argument list that has exactly
- // one expression, an implicit conversion sequence cannot be formed if C is
- // reference-related to the type that the argument would have after the
- // application of the user-defined conversion (if any) and before the final
- // standard conversion sequence.
- auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl.getDecl());
- if (Shadow && Args.size() == 1 && !isa<InitListExpr>(Args.front())) {
- bool DerivedToBase, ObjCConversion, ObjCLifetimeConversion;
- QualType ConvertedArgumentType = Args.front()->getType();
- if (Candidate.Conversions[0].isUserDefined())
- ConvertedArgumentType =
- Candidate.Conversions[0].UserDefined.After.getFromType();
- if (CompareReferenceRelationship(Args.front()->getLocStart(),
- Context.getRecordType(Shadow->getParent()),
- ConvertedArgumentType, DerivedToBase,
- ObjCConversion,
- ObjCLifetimeConversion) >= Ref_Related) {
- Candidate.Viable = false;
- Candidate.FailureKind = ovl_fail_inhctor_slice;
- return;
- }
- }
-
if (EnableIfAttr *FailedAttr = CheckEnableIf(Function, Args)) {
Candidate.Viable = false;
Candidate.FailureKind = ovl_fail_enable_if;
@@ -10222,8 +10219,13 @@ static void NoteFunctionCandidate(Sema &S, OverloadCandidate *Cand,
return DiagnoseOpenCLExtensionDisabled(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);
+ diag::note_ovl_candidate_inherited_constructor_slice)
+ << (Fn->getPrimaryTemplate() ? 1 : 0)
+ << Fn->getParamDecl(0)->getType()->isRValueReferenceType();
MaybeEmitInheritedConstructorNote(S, Cand->FoundDecl);
return;
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp
index 8ad5b5951ea3..ad1e89a0ca64 100644
--- a/lib/Sema/SemaTemplate.cpp
+++ b/lib/Sema/SemaTemplate.cpp
@@ -5127,18 +5127,22 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
if (CTAK == CTAK_Deduced &&
!Context.hasSameType(ParamType.getNonLValueExprType(Context),
Arg->getType())) {
- // C++ [temp.deduct.type]p17: (DR1770)
- // If P has a form that contains <i>, and if the type of i differs from
- // the type of the corresponding template parameter of the template named
- // by the enclosing simple-template-id, deduction fails.
- //
- // Note that CTAK will be CTAK_DeducedFromArrayBound if the form was [i]
- // rather than <i>.
- //
- // FIXME: We interpret the 'i' here as referring to the expression
- // denoting the non-type template parameter rather than the parameter
- // itself, and so strip off references before comparing types. It's
- // not clear how this is supposed to work for references.
+ // FIXME: If either type is dependent, we skip the check. This isn't
+ // correct, since during deduction we're supposed to have replaced each
+ // template parameter with some unique (non-dependent) placeholder.
+ // FIXME: If the argument type contains 'auto', we carry on and fail the
+ // type check in order to force specific types to be more specialized than
+ // 'auto'. It's not clear how partial ordering with 'auto' is supposed to
+ // work.
+ if ((ParamType->isDependentType() || Arg->isTypeDependent()) &&
+ !Arg->getType()->getContainedAutoType()) {
+ Converted = TemplateArgument(Arg);
+ return Arg;
+ }
+ // FIXME: This attempts to implement C++ [temp.deduct.type]p17. Per DR1770,
+ // we should actually be checking the type of the template argument in P,
+ // not the type of the template argument deduced from A, against the
+ // template parameter type.
Diag(StartLoc, diag::err_deduced_non_type_template_arg_type_mismatch)
<< Arg->getType()
<< ParamType.getUnqualifiedType();