Skip to content

Commit 5e40170

Browse files
committed
AST: remove invalid static_assert
This removes a set of static assertions that did not do what they were supposed to do. The static assertions were attempting to ensure that the functions are different. However, the address of a function is *not* a constant expression and cannot be used in a static assertion. Furthermore, the static assert is either tautologically true or will be caught as a compile error on the dispatch. The methods being checked here are non-virtual. The PFN that was being computed is tautologically different as there is no virtuality and the two methods must be different (barring any ICF coalescing that may be performed by the linker or by LTO). The method must exist, otherwise, the dispatch itself will trigger a resolution failure. Effectively, the static assertionss did not compute anything as a result: - the method's existence is checked by the dispatch - the address of the function is always different This was identified by building with GCC 7.
1 parent 746b58e commit 5e40170

File tree

1 file changed

+0
-18
lines changed

1 file changed

+0
-18
lines changed

lib/AST/ProtocolConformance.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -200,39 +200,21 @@ void *ProtocolConformance::operator new(size_t bytes, ASTContext &context,
200200
#define CONFORMANCE_SUBCLASS_DISPATCH(Method, Args) \
201201
switch (getKind()) { \
202202
case ProtocolConformanceKind::Normal: \
203-
static_assert(&ProtocolConformance::Method != \
204-
&NormalProtocolConformance::Method, \
205-
"Must override NormalProtocolConformance::" #Method); \
206203
return cast<NormalProtocolConformance>(this)->Method Args; \
207204
case ProtocolConformanceKind::Self: \
208-
static_assert(&ProtocolConformance::Method != \
209-
&SelfProtocolConformance::Method, \
210-
"Must override SelfProtocolConformance::" #Method); \
211205
return cast<SelfProtocolConformance>(this)->Method Args; \
212206
case ProtocolConformanceKind::Specialized: \
213-
static_assert(&ProtocolConformance::Method != \
214-
&SpecializedProtocolConformance::Method, \
215-
"Must override SpecializedProtocolConformance::" #Method); \
216207
return cast<SpecializedProtocolConformance>(this)->Method Args; \
217208
case ProtocolConformanceKind::Inherited: \
218-
static_assert(&ProtocolConformance::Method != \
219-
&InheritedProtocolConformance::Method, \
220-
"Must override InheritedProtocolConformance::" #Method); \
221209
return cast<InheritedProtocolConformance>(this)->Method Args; \
222210
} \
223211
llvm_unreachable("bad ProtocolConformanceKind");
224212

225213
#define ROOT_CONFORMANCE_SUBCLASS_DISPATCH(Method, Args) \
226214
switch (getKind()) { \
227215
case ProtocolConformanceKind::Normal: \
228-
static_assert(&RootProtocolConformance::Method != \
229-
&NormalProtocolConformance::Method, \
230-
"Must override NormalProtocolConformance::" #Method); \
231216
return cast<NormalProtocolConformance>(this)->Method Args; \
232217
case ProtocolConformanceKind::Self: \
233-
static_assert(&RootProtocolConformance::Method != \
234-
&SelfProtocolConformance::Method, \
235-
"Must override SelfProtocolConformance::" #Method); \
236218
return cast<SelfProtocolConformance>(this)->Method Args; \
237219
case ProtocolConformanceKind::Specialized: \
238220
case ProtocolConformanceKind::Inherited: \

0 commit comments

Comments
 (0)