Skip to content

Commit f914b16

Browse files
committed
[FOLD]
1 parent 5086c98 commit f914b16

File tree

5 files changed

+31
-31
lines changed

5 files changed

+31
-31
lines changed

clang/lib/Sema/SemaInit.cpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6576,12 +6576,12 @@ void InitializationSequence::InitializeFrom(Sema &S,
65766576

65776577
AddPassByIndirectCopyRestoreStep(DestType, ShouldCopy);
65786578
} else if (ICS.isBad()) {
6579-
DeclAccessPair dap;
6580-
if (isLibstdcxxPointerReturnFalseHack(S, Entity, Initializer)) {
6579+
if (isLibstdcxxPointerReturnFalseHack(S, Entity, Initializer))
65816580
AddZeroInitializationStep(Entity.getType());
6582-
} else if (Initializer->getType() == Context.OverloadTy &&
6583-
!S.ResolveAddressOfOverloadedFunction(Initializer, DestType,
6584-
false, dap))
6581+
else if (DeclAccessPair Found;
6582+
Initializer->getType() == Context.OverloadTy &&
6583+
!S.ResolveAddressOfOverloadedFunction(Initializer, DestType,
6584+
/*Complain=*/false, Found))
65856585
SetFailed(InitializationSequence::FK_AddressOfOverloadFailed);
65866586
else if (Initializer->getType()->isFunctionType() &&
65876587
isExprAnUnaddressableFunction(S, Initializer))
@@ -9641,6 +9641,8 @@ bool InitializationSequence::Diagnose(Sema &S,
96419641
if (!Failed())
96429642
return false;
96439643

9644+
QualType DestType = Entity.getType();
9645+
96449646
// When we want to diagnose only one element of a braced-init-list,
96459647
// we need to factor it out.
96469648
Expr *OnlyArg;
@@ -9650,11 +9652,21 @@ bool InitializationSequence::Diagnose(Sema &S,
96509652
OnlyArg = List->getInit(0);
96519653
else
96529654
OnlyArg = Args[0];
9655+
9656+
if (OnlyArg->getType() == S.Context.OverloadTy) {
9657+
DeclAccessPair Found;
9658+
if (FunctionDecl *FD = S.ResolveAddressOfOverloadedFunction(
9659+
OnlyArg, DestType.getNonReferenceType(), /*Complain=*/false,
9660+
Found)) {
9661+
if (Expr *Resolved =
9662+
S.FixOverloadedFunctionReference(OnlyArg, Found, FD).get())
9663+
OnlyArg = Resolved;
9664+
}
9665+
}
96539666
}
96549667
else
96559668
OnlyArg = nullptr;
96569669

9657-
QualType DestType = Entity.getType();
96589670
switch (Failure) {
96599671
case FK_TooManyInitsForReference:
96609672
// FIXME: Customize for the initialized entity?

clang/lib/Sema/SemaTemplateDeduction.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,11 +1231,11 @@ bool Sema::isSameOrCompatibleFunctionType(QualType P, QualType A) {
12311231
// Noreturn and noexcept adjustment.
12321232
QualType AdjustedParam;
12331233
if (IsFunctionConversion(P, A, AdjustedParam))
1234-
return Context.hasSameType(AdjustedParam, A);
1234+
return Context.hasSameFunctionTypeIgnoringExceptionSpec(AdjustedParam, A);
12351235

12361236
// FIXME: Compatible calling conventions.
12371237

1238-
return Context.hasSameType(P, A);
1238+
return Context.hasSameFunctionTypeIgnoringExceptionSpec(P, A);
12391239
}
12401240

12411241
/// Get the index of the first template parameter that was originally from the
@@ -4593,13 +4593,6 @@ TemplateDeductionResult Sema::DeduceTemplateArguments(
45934593
Info.getLocation()))
45944594
return TemplateDeductionResult::MiscellaneousDeductionFailure;
45954595

4596-
auto *SpecializationFPT =
4597-
Specialization->getType()->castAs<FunctionProtoType>();
4598-
if (IsAddressOfFunction && getLangOpts().CPlusPlus17 &&
4599-
isUnresolvedExceptionSpec(SpecializationFPT->getExceptionSpecType()) &&
4600-
!ResolveExceptionSpec(Info.getLocation(), SpecializationFPT))
4601-
return TemplateDeductionResult::MiscellaneousDeductionFailure;
4602-
46034596
// Adjust the exception specification of the argument to match the
46044597
// substituted and resolved type we just formed. (Calling convention and
46054598
// noreturn can't be dependent, so we don't actually need this for them

clang/test/CXX/drs/dr13xx.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -281,13 +281,10 @@ namespace cwg1330 { // cwg1330: 4 c++11
281281
decltype(f<char>()) f2; // #cwg1330-f-char
282282
bool f3 = noexcept(f<float>()); /// #cwg1330-f-float
283283
#endif
284-
// In C++17 onwards, substituting explicit template arguments into the
285-
// function type substitutes into the exception specification (because it's
286-
// part of the type). In earlier languages, we don't notice there's a problem
287-
// until we've already started to instantiate.
288284
template int f<short>(); // #cwg1330-f-short
289-
// since-cxx17-error@-1 {{explicit instantiation of 'f' does not refer to a function template, variable template, member function, member class, or static data member}}
290-
// since-cxx17-note@#cwg1330-f {{candidate template ignored: substitution failure [with T = short]: type 'short' cannot be used prior to '::' because it has no members}}
285+
// since-cxx17-error@#cwg1330-f {{type 'short' cannot be used prior to '::' because it has no members}}
286+
// since-cxx17-note@#cwg1330-f {{in instantiation of exception specification for 'f<short>' requested here}}
287+
// since-cxx17-note@#cwg1330-f-short {{in instantiation of function template specialization 'cwg1330::f<short>' requested here}}
291288

292289
template<typename T> struct C {
293290
C() throw(typename T::type); // #cwg1330-C
@@ -500,7 +497,7 @@ namespace cwg1359 { // cwg1359: 3.5
500497
union B { constexpr B() = default; int a; }; // #cwg1359-B
501498
// cxx11-17-error@-1 {{defaulted definition of default constructor cannot be marked constexpr before C++23}}
502499
union C { constexpr C() = default; int a, b; }; // #cwg1359-C
503-
// cxx11-17-error@-1 {{defaulted definition of default constructor cannot be marked constexpr}}
500+
// cxx11-17-error@-1 {{defaulted definition of default constructor cannot be marked constexpr}}
504501
struct X { constexpr X() = default; union {}; };
505502
// since-cxx11-error@-1 {{declaration does not declare anything}}
506503
struct Y { constexpr Y() = default; union { int a; }; }; // #cwg1359-Y
@@ -720,7 +717,7 @@ struct A {
720717
} // namespace cwg1397
721718

722719
namespace cwg1399 { // cwg1399: dup 1388
723-
template<typename ...T> void f(T..., int, T...) {} // #cwg1399-f
720+
template<typename ...T> void f(T..., int, T...) {} // #cwg1399-f
724721
// cxx98-error@-1 {{variadic templates are a C++11 extension}}
725722
void g() {
726723
f(0);

clang/test/SemaCXX/cxx1z-noexcept-function-type.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ template<typename A, typename B> void redecl3() throw(B); // expected-error {{do
1818

1919
typedef int I;
2020
template<bool B> void redecl4(I) noexcept(B);
21-
template<bool B> void redecl4(I) noexcept(B); // expected-note {{could not match 'void (I) noexcept(false)' (aka 'void (int) noexcept(false)') against 'void (int) noexcept'}}
21+
template<bool B> void redecl4(I) noexcept(B);
2222

2323
void (*init_with_exact_type_a)(int) noexcept = redecl4<true>;
2424
void (*init_with_mismatched_type_a)(int) = redecl4<true>;
@@ -27,7 +27,7 @@ using DeducedType_a = decltype(deduce_auto_from_noexcept_function_ptr_a);
2727
using DeducedType_a = void (*)(int) noexcept;
2828

2929
void (*init_with_exact_type_b)(int) = redecl4<false>;
30-
void (*init_with_mismatched_type_b)(int) noexcept = redecl4<false>; // expected-error {{does not match required type}}
30+
void (*init_with_mismatched_type_b)(int) noexcept = redecl4<false>; // expected-error {{cannot initialize a variable of type}}
3131
auto deduce_auto_from_noexcept_function_ptr_b = redecl4<false>;
3232
using DeducedType_b = decltype(deduce_auto_from_noexcept_function_ptr_b);
3333
using DeducedType_b = void (*)(int);

clang/test/SemaTemplate/temp_arg_type.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ A<0> *a1; // expected-error{{template argument for template type parameter must
1111
A<A> *a2; // expected-error{{use of class template 'A' requires template arguments}}
1212

1313
A<int> *a3;
14-
A<int()> *a4;
14+
A<int()> *a4;
1515
A<int(float)> *a5;
1616
A<A<int> > *a6;
1717

@@ -95,15 +95,13 @@ namespace deduce_noexcept {
9595
template void dep() noexcept(true); // expected-error {{does not refer to a function template}}
9696
template void dep() noexcept(false); // expected-error {{does not refer to a function template}}
9797

98-
// FIXME: It's also not clear whether this should be valid: do we substitute
99-
// into the function type (including the exception specification) or not?
100-
template<typename T> typename T::type1 f() noexcept(T::a);
101-
template<typename T> typename T::type2 f() noexcept(T::b) {}
98+
template<typename T> typename T::type1 f() noexcept(T::a); // expected-note {{candidate}}
99+
template<typename T> typename T::type2 f() noexcept(T::b) {} // expected-note {{candidate}}
102100
struct X {
103101
static constexpr bool b = true;
104102
using type1 = void;
105103
using type2 = void;
106104
};
107-
template void f<X>();
105+
template void f<X>(); // expected-error {{partial ordering for explicit instantiation of 'f' is ambiguous}}
108106
}
109107
#endif

0 commit comments

Comments
 (0)