Skip to content

Commit

Permalink
[clang] Add tests for CWG1800-1804 (#77509)
Browse files Browse the repository at this point in the history
Covers C++ core issues 1800, 1801, 1802, 1803, 1804.
  • Loading branch information
Endilll committed Jan 10, 2024
1 parent 084f1c2 commit d0918a2
Show file tree
Hide file tree
Showing 2 changed files with 166 additions and 13 deletions.
167 changes: 160 additions & 7 deletions clang/test/CXX/drs/dr18xx.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,169 @@
// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify=expected,cxx98 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify=expected,cxx11-17,since-cxx11 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify=expected,cxx11-17,since-cxx11,since-cxx14 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify=expected,cxx11-17,since-cxx11,since-cxx14 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx20,since-cxx11,since-cxx14 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx20,since-cxx11,since-cxx14 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++2c -triple x86_64-unknown-unknown %s -verify=expected,since-cxx20,since-cxx11,since-cxx14 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify=expected,cxx98-14,cxx98 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify=expected,cxx98-14,cxx11-17,since-cxx11 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify=expected,cxx98-14,cxx11-17,since-cxx11,since-cxx14 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx17,cxx11-17,since-cxx11,since-cxx14 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx17,since-cxx20,since-cxx11,since-cxx14 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx17,since-cxx20,since-cxx11,since-cxx14 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++2c -triple x86_64-unknown-unknown %s -verify=expected,since-cxx17,since-cxx20,since-cxx11,since-cxx14 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors

#if __cplusplus == 199711L
#define static_assert(...) __extension__ _Static_assert(__VA_ARGS__)
// cxx98-error@-1 {{variadic macros are a C99 feature}}
#endif

namespace dr1800 { // dr1800: 2.9
struct A { union { int n; }; };
static_assert(__is_same(__decltype(&A::n), int A::*), "");
} // namespace dr1800

namespace dr1801 { // dr1801: 2.8
static union {
int i;
};

template <int &> struct S {}; // #dr1801-S
S<i> V; // #dr1801-S-i
// cxx98-14-error@-1 {{non-type template argument does not refer to any declaration}}
// cxx98-14-note@#dr1801-S {{template parameter is declared here}}
// since-cxx17-error@#dr1801-S-i {{non-type template argument refers to subobject '.i'}}
}

namespace dr1802 { // dr1802: 3.1
#if __cplusplus >= 201103L
// Using a Wikipedia example of surrogate pair:
// https://en.wikipedia.org/wiki/UTF-16#Examples
constexpr char16_t a[3] = u"\U00010437";
static_assert(a[0] == 0xD801, "");
static_assert(a[1] == 0xDC37, "");
static_assert(a[2] == 0x0, "");
#endif
} // namespace dr1802

namespace dr1803 { // dr1803: 2.9
#if __cplusplus >= 201103L
struct A {
enum E : int;
enum E : int {};
enum class EC;
enum class EC {};
enum struct ES;
enum struct ES {};
};
#endif
} // namespace dr1803

namespace dr1804 { // dr1804: 2.7
template <typename, typename>
struct A {
void f1();

template <typename V>
void f2(V);

class B {
void f3();
};

template <typename>
class C {
void f4();
};
};

template <typename U>
struct A<int, U> {
void f1();

template <typename V>
void f2(V);

class B {
void f3();
};

template <typename>
class C {
void f4();
};
};

class D {
int i;

template <typename, typename>
friend struct A;
};

template <typename U>
struct A<double, U> {
void f1();

template <typename V>
void f2(V);

class B {
void f3();
};

template <typename>
class C {
void f4();
};
};

template <typename U>
void A<int, U>::f1() {
D d;
d.i = 0;
}

template <typename U>
void A<double, U>::f1() {
D d;
d.i = 0;
}

template <typename U>
template <typename V>
void A<int, U>::f2(V) {
D d;
d.i = 0;
}

template <typename U>
template <typename V>
void A<double, U>::f2(V) {
D d;
d.i = 0;
}

template <typename U>
void A<int, U>::B::f3() {
D d;
d.i = 0;
}

template <typename U>
void A<double, U>::B::f3() {
D d;
d.i = 0;
}

template <typename U>
template <typename V>
void A<int, U>::C<V>::f4() {
D d;
d.i = 0;
}

template <typename U>
template <typename V>
void A<double, U>::C<V>::f4() {
D d;
d.i = 0;
}
} // namespace dr1804

namespace dr1812 { // dr1812: no
// NB: dup 1710
#if __cplusplus >= 201103L
Expand Down
12 changes: 6 additions & 6 deletions clang/www/cxx_dr_status.html
Original file line number Diff line number Diff line change
Expand Up @@ -2661,7 +2661,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
<td><a href="https://cplusplus.github.io/CWG/issues/437.html">437</a></td>
<td>CD1</td>
<td>Is type of class allowed in member function exception specification?</td>
<td class="full" align="center">Superseded by <a href="#1308">1308</a></td>
<td class="none" align="center">Superseded by <a href="#1308">1308</a></td>
</tr>
<tr id="438">
<td><a href="https://cplusplus.github.io/CWG/issues/438.html">438</a></td>
Expand Down Expand Up @@ -10607,31 +10607,31 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
<td><a href="https://cplusplus.github.io/CWG/issues/1800.html">1800</a></td>
<td>CD4</td>
<td>Pointer to member of nested anonymous union</td>
<td class="none" align="center">Unknown</td>
<td class="full" align="center">Clang 2.9</td>
</tr>
<tr id="1801">
<td><a href="https://cplusplus.github.io/CWG/issues/1801.html">1801</a></td>
<td>CD4</td>
<td>Kind of expression referring to member of anonymous union</td>
<td class="none" align="center">Unknown</td>
<td class="full" align="center">Clang 2.8</td>
</tr>
<tr id="1802">
<td><a href="https://cplusplus.github.io/CWG/issues/1802.html">1802</a></td>
<td>CD4</td>
<td><TT>char16_t</TT> string literals and surrogate pairs</td>
<td class="none" align="center">Unknown</td>
<td class="full" align="center">Clang 3.1</td>
</tr>
<tr id="1803">
<td><a href="https://cplusplus.github.io/CWG/issues/1803.html">1803</a></td>
<td>CD5</td>
<td><I>opaque-enum-declaration</I> as <I>member-declaration</I></td>
<td class="none" align="center">Unknown</td>
<td class="full" align="center">Clang 2.9</td>
</tr>
<tr id="1804">
<td><a href="https://cplusplus.github.io/CWG/issues/1804.html">1804</a></td>
<td>CD4</td>
<td>Partial specialization and friendship</td>
<td class="none" align="center">Unknown</td>
<td class="full" align="center">Clang 2.7</td>
</tr>
<tr id="1805">
<td><a href="https://cplusplus.github.io/CWG/issues/1805.html">1805</a></td>
Expand Down

0 comments on commit d0918a2

Please sign in to comment.