Files
RedBear-OS/local/recipes/dev/libclc/source/clang/test/Parser/cxx2c-variadic-friends.cpp
T
vasilito cb424d7448 build: static patch-sanity linter (shift-left the malformed-patch class)
verify-patch-sanity.py validates every active recipe .patch has internally-
consistent hunk line counts — catching the 'malformed patch at line N' failure
at commit/CI/preflight time instead of hours into a cook. This cycle hit that
class three times (qtwaylandscanner, sddm, xwayland), each only discovered when
cookbook tried to apply the patch.

Running it across the repo found 29 latent malformed patches (validated against
GNU patch: e.g. relibc/P3-sysv-ipc reproduces 'malformed patch at line 22').
They were harmless only because they sit in vendored recipes (baked, not re-
applied) — but would fail on any version-bump re-derivation. --fix recounts the
hunk headers (body untouched) and repaired all 29.

Wired into build-preflight.sh (Phase 1.0D) and redbear-ci.yml, with a unit test
(test-patch-sanity.sh). Skips archived/legacy trees and unvalidatable formats
(empty placeholders, bare-@@ git hunks).
2026-08-01 05:13:02 +03:00

92 lines
3.5 KiB
C++

// RUN: %clang_cc1 -fsyntax-only -verify -std=c++2c %s
template <typename> struct TS; // #template
struct Errors {
friend int, int;
friend int, long, char;
// We simply diagnose and ignore the '...' here.
friend float...; // expected-error {{pack expansion does not contain any unexpanded parameter packs}}
friend short..., unsigned, unsigned short...; // expected-error 2 {{pack expansion does not contain any unexpanded parameter packs}}
template <typename>
friend struct TS, int; // expected-error {{a friend declaration that befriends a template must contain exactly one type-specifier}}
double friend; // expected-error {{'friend' must appear first in a non-function declaration}}
double friend, double; // expected-error {{expected member name or ';' after declaration specifiers}}
};
template <typename>
struct C { template<class T> class Nested; };
template <typename, typename>
struct D { template<class T> class Nested; };
template <bool>
struct E { template<class T> class Nested; };
template<class... Ts> // expected-note {{template parameter is declared here}}
struct VS {
friend Ts...;
friend class Ts...; // expected-error {{declaration of 'Ts' shadows template parameter}}
// expected-error@-1 {{pack expansion does not contain any unexpanded parameter packs}}
// TODO: Fix-it hint to insert '...'.
friend Ts; // expected-error {{friend declaration contains unexpanded parameter pack}}
template<class... Us>
friend Us...; // expected-error {{friend type templates must use an elaborated type}}
template<class... Us> // expected-note {{is declared here}}
friend class Us...; // expected-error {{declaration of 'Us' shadows template parameter}}
template<class U>
friend class C<Ts>::template Nested<U>...; // expected-error {{cannot specialize a dependent template}}
template<class... Us>
friend class C<Ts...>::template Nested<Us>...; // expected-error {{cannot specialize a dependent template}}
// Nonsense (see CWG 2917).
template<class... Us>
friend class C<Us>::Nested...; // expected-error {{friend declaration expands pack 'Us' that is declared it its own template parameter list}}
template<bool... Bs>
friend class E<Bs>::Nested...; // expected-error {{friend declaration expands pack 'Bs' that is declared it its own template parameter list}}
// FIXME: Both of these should be valid, but we can't handle these at
// the moment because the NNS is dependent.
template<class ...T>
friend class TS<Ts>::Nested...; // expected-warning {{dependent nested name specifier 'TS<Ts>' for friend template declaration is not supported; ignoring this friend declaration}}
template<class T>
friend class D<T, Ts>::Nested...; // expected-warning {{dependent nested name specifier 'D<T, Ts>' for friend class declaration is not supported; turning off access control for 'VS'}}
};
namespace length_mismatch {
struct A {
template <typename...>
struct Nested {
struct Foo{};
};
};
template <typename ...Ts>
struct S {
template <typename ...Us>
struct T {
// expected-error@+2 {{pack expansion contains parameter packs 'Ts' and 'Us' that have different lengths (1 vs. 2)}}
// expected-error@+1 {{pack expansion contains parameter packs 'Ts' and 'Us' that have different lengths (2 vs. 1)}}
friend class Ts::template Nested<Us>::Foo...;
};
};
void f() {
S<A>::T<int> s;
S<A, A>::T<int, long> s2;
S<A>::T<int, long> s3; // expected-note {{in instantiation of}}
S<A, A>::T<int> s4; // expected-note {{in instantiation of}}
}
}