Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,7 @@ Bug Fixes to C++ Support
- Fix for clang incorrectly rejecting the default construction of a union with
nontrivial member when another member has an initializer. (#GH81774)
- Fixed a template depth issue when parsing lambdas inside a type constraint. (#GH162092)
- Fix the support of zero-length arrays in SFINAE context. (#GH170040)
- Diagnose unresolved overload sets in non-dependent compound requirements. (#GH51246) (#GH97753)
- Fix a crash when extracting unavailable member type from alias in template deduction. (#GH165560)
- Fix incorrect diagnostics for lambdas with init-captures inside braced initializers. (#GH163498)
Expand Down
2 changes: 2 additions & 0 deletions clang/lib/Sema/SemaType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2259,6 +2259,8 @@ QualType Sema::BuildArrayType(QualType T, ArraySizeModifier ASM,
isSFINAEContext() ? diag::err_typecheck_zero_array_size
: diag::ext_typecheck_zero_array_size)
<< 0 << ArraySize->getSourceRange();
if (isSFINAEContext())
return QualType();
}

// Is the array too large?
Expand Down
17 changes: 16 additions & 1 deletion clang/test/SemaCXX/zero-length-arrays.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s

class Foo {
~Foo();
Expand All @@ -19,7 +20,7 @@ class Bar {
Foo foos3[2][0];

public:
Bar(): foo_count(0) { }
Bar(): foo_count(0) { }
~Bar() { }
};

Expand All @@ -33,3 +34,17 @@ void testBar() {
#endif
b = b2;
}

namespace GH170040 {
#if __cplusplus >= 202002L
template <int N> struct Foo {
operator int() const requires(N == 2);
template <int I = 0, char (*)[(I)] = nullptr> operator long() const;
};

void test () {
Foo<2> foo;
long bar = foo;
}
#endif
}