mirror of
https://github.com/github/codeql.git
synced 2025-12-18 09:43:15 +01:00
60 lines
1020 B
C++
60 lines
1020 B
C++
int topLevelFriend();
|
|
|
|
class HasFriendFunction {
|
|
public:
|
|
static int friendFunction();
|
|
};
|
|
|
|
class C {
|
|
friend class Friend;
|
|
friend int f() { return 1; }
|
|
friend int topLevelFriend();
|
|
friend int HasFriendFunction::friendFunction();
|
|
|
|
C();
|
|
C(const C& c) {}
|
|
static int return2() { return 2; }
|
|
|
|
class Nested {
|
|
Nested();
|
|
int nested1() {
|
|
struct Local {
|
|
int localOfNested() { return return2(); }
|
|
} l;
|
|
return l.localOfNested();
|
|
}
|
|
struct Nested2 {
|
|
void nested2();
|
|
};
|
|
};
|
|
};
|
|
|
|
class Friend {
|
|
int f() {
|
|
auto lambdaFriend = [](int a, int b) { return a + b + C::return2(); };
|
|
return lambdaFriend(1, 2);
|
|
}
|
|
};
|
|
|
|
class NotFriend {
|
|
int f() {
|
|
auto lambdaNotFriend = [](int a, int b) { return a + b; };
|
|
return lambdaNotFriend(1, 2);
|
|
}
|
|
};
|
|
|
|
int topLevelFriend() {
|
|
struct LocalOfFriend {
|
|
int localOfFriend() { return C::return2(); }
|
|
} l;
|
|
return l.localOfFriend();
|
|
}
|
|
|
|
class DerivesFromC : public C {
|
|
int f();
|
|
};
|
|
|
|
C::C() {
|
|
(void)return2();
|
|
}
|