Skip to content

Commit 7b15eba

Browse files
committed
feedback
1 parent c63f3f8 commit 7b15eba

File tree

3 files changed

+47
-23
lines changed

3 files changed

+47
-23
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ Bug Fixes to C++ Support
767767
- Clang could incorrectly instantiate functions in discarded contexts (#GH140449)
768768
- Fix instantiation of default-initialized variable template specialization. (#GH140632) (#GH140622)
769769
- Clang modules now allow a module and its user to differ on TrivialAutoVarInit*
770-
- Fixed a C++20 access checking bug when initializing non-aggregates in default arguments (#GH83608)
770+
- Fixed an access checking bug when initializing non-aggregates in default arguments (#GH62444), (#GH83608)
771771

772772
Bug Fixes to AST Handling
773773
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/test/SemaCXX/access-control-check.cpp

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,49 @@ class N : M,P {
1313
N() {}
1414
int PR() { return iP + PPR(); } // expected-error 2 {{private member of 'P'}}
1515
};
16+
17+
namespace GH83608 {
18+
19+
class single;
20+
21+
class check_constructible {
22+
// This makes the class a non-aggregate, which enforces us to check
23+
// the constructor when initializing.
24+
check_constructible() {}
25+
26+
friend class single;
27+
};
28+
29+
struct single {
30+
template <class T> single(T u, check_constructible = {}) {}
31+
};
32+
33+
// We perform access checking when substituting into the default argument.
34+
// Make sure it runs within the context of 'single'.
35+
single x(0);
36+
37+
}
38+
39+
namespace GH62444 {
40+
41+
struct B {
42+
friend struct A;
43+
private:
44+
B(int); // #B
45+
};
46+
47+
template<class T>
48+
int f(T = 0); // #Decl
49+
50+
struct A {
51+
A() {
52+
int i = f<B>();
53+
// expected-error@#Decl {{calling a private constructor}}
54+
// expected-note@-2 {{in instantiation of default function argument}}
55+
// expected-note@#B {{declared private}}
56+
}
57+
};
58+
59+
int i = f<B>();
60+
61+
}

clang/test/SemaTemplate/default-arguments.cpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// RUN: %clang_cc1 -fsyntax-only -verify %s
22
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
33
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
4-
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s
54
template<typename T, int N = 2> struct X; // expected-note{{template is declared here}}
65

76
X<int, 1> *x1;
@@ -283,25 +282,4 @@ static_assert(S<short *>().SizeOfT<char>() == sizeof(short *), "");
283282

284283
} // namespace GH68490
285284

286-
namespace GH83608 {
287-
288-
class single;
289-
290-
class check_constructible {
291-
// This makes it a non-aggregate in C++20+.
292-
check_constructible() = default;
293-
294-
friend class single;
295-
};
296-
297-
struct single {
298-
template <class T> single(T u, check_constructible = {}) {}
299-
};
300-
301-
// We perform access checking when substituting into the default argument.
302-
// Make sure it runs within class single.
303-
single x(0);
304-
305-
}
306-
307285
#endif

0 commit comments

Comments
 (0)