mirror of
https://github.com/github/codeql.git
synced 2025-12-17 09:13:20 +01:00
Making `constexpr` imply `const` was correct for C++11 and was a correct emulation of a GCC bug on GCC < 5.0. This test confirms that the problem isn't there in C++20.
66 lines
1.4 KiB
C++
66 lines
1.4 KiB
C++
|
|
void afun(void) {
|
|
int x = 5;
|
|
auto x2 = x;
|
|
register int y;
|
|
}
|
|
|
|
class MyClass {
|
|
public:
|
|
explicit MyClass (int n);
|
|
int publicInt;
|
|
void publicFun(void) {}
|
|
virtual int getInt() = 0;
|
|
virtual int f();
|
|
private:
|
|
int privateInt;
|
|
mutable int mutableInt;
|
|
void privateFun(void) {}
|
|
protected:
|
|
int protectedInt;
|
|
void protectedFun(void) {}
|
|
};
|
|
|
|
class MyClass2: public MyClass {
|
|
public:
|
|
virtual int f() override;
|
|
};
|
|
|
|
class SomeClass {
|
|
public:
|
|
int fun(void);
|
|
};
|
|
int SomeClass::fun(void) {}
|
|
|
|
class AnotherClass {
|
|
friend class MyClass;
|
|
friend int SomeClass::fun();
|
|
};
|
|
|
|
extern int someFun(int x);
|
|
extern "C" int someFun2(int x);
|
|
extern "C" {
|
|
int someFun3(int x);
|
|
static int someFun4(int x);
|
|
}
|
|
|
|
typedef int *const const_pointer;
|
|
|
|
typedef volatile const_pointer volatile_const_pointer;
|
|
typedef volatile_const_pointer volatile_const_pointer2;
|
|
|
|
volatile_const_pointer2 vci = 0;
|
|
typedef decltype(vci) volatile_const_pointer3;
|
|
typedef __restrict volatile_const_pointer3 volatile_const_restrict_pointer;
|
|
|
|
template<typename T> using Const = const T;
|
|
|
|
using Const_int = Const<int>;
|
|
|
|
typedef volatile Const_int volatile_Const_int;
|
|
|
|
class TestConstexpr {
|
|
constexpr int member_constexpr() { return 0; } // const in C++11
|
|
constexpr int member_const_constexpr() const { return 0; }
|
|
};
|