mirror of
https://github.com/github/codeql.git
synced 2026-04-26 17:25:19 +02:00
C++: Confirm correct behaviour on C++20
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.
This commit is contained in:
10
cpp/ql/test/library-tests/specifiers2/cpp20.cpp
Normal file
10
cpp/ql/test/library-tests/specifiers2/cpp20.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
// semmle-extractor-options: --edg --clang --edg --c++20
|
||||
|
||||
namespace cpp20 {
|
||||
|
||||
class TestConstexpr {
|
||||
constexpr int member_constexpr() { return 0; } // not const in C++ >= 14
|
||||
constexpr int member_const_constexpr() const { return 0; }
|
||||
};
|
||||
|
||||
} // namespace cpp20
|
||||
@@ -1,5 +1,22 @@
|
||||
| Class | specifiers2pp.cpp:8:7:8:13 | MyClass | MyClass | abstract |
|
||||
| Class | specifiers2pp.cpp:24:7:24:14 | MyClass2 | MyClass2 | abstract |
|
||||
| Function | cpp20.cpp:5:7:5:7 | operator= | operator= | extern |
|
||||
| Function | cpp20.cpp:5:7:5:7 | operator= | operator= | extern |
|
||||
| Function | cpp20.cpp:5:7:5:7 | operator= | operator= | inline |
|
||||
| Function | cpp20.cpp:5:7:5:7 | operator= | operator= | inline |
|
||||
| Function | cpp20.cpp:5:7:5:7 | operator= | operator= | is_constexpr |
|
||||
| Function | cpp20.cpp:5:7:5:7 | operator= | operator= | is_constexpr |
|
||||
| Function | cpp20.cpp:5:7:5:7 | operator= | operator= | public |
|
||||
| Function | cpp20.cpp:5:7:5:7 | operator= | operator= | public |
|
||||
| Function | cpp20.cpp:6:19:6:34 | member_constexpr | member_constexpr | declared_constexpr |
|
||||
| Function | cpp20.cpp:6:19:6:34 | member_constexpr | member_constexpr | inline |
|
||||
| Function | cpp20.cpp:6:19:6:34 | member_constexpr | member_constexpr | is_constexpr |
|
||||
| Function | cpp20.cpp:6:19:6:34 | member_constexpr | member_constexpr | private |
|
||||
| Function | cpp20.cpp:7:19:7:40 | member_const_constexpr | member_const_constexpr | const |
|
||||
| Function | cpp20.cpp:7:19:7:40 | member_const_constexpr | member_const_constexpr | declared_constexpr |
|
||||
| Function | cpp20.cpp:7:19:7:40 | member_const_constexpr | member_const_constexpr | inline |
|
||||
| Function | cpp20.cpp:7:19:7:40 | member_const_constexpr | member_const_constexpr | is_constexpr |
|
||||
| Function | cpp20.cpp:7:19:7:40 | member_const_constexpr | member_const_constexpr | private |
|
||||
| Function | specifiers2.c:11:6:11:6 | f | f | extern |
|
||||
| Function | specifiers2.c:12:13:12:13 | f | f | extern |
|
||||
| Function | specifiers2.c:13:13:13:13 | f | f | extern |
|
||||
|
||||
@@ -60,6 +60,6 @@ using Const_int = Const<int>;
|
||||
typedef volatile Const_int volatile_Const_int;
|
||||
|
||||
class TestConstexpr {
|
||||
constexpr int member_constexpr() { return 0; }
|
||||
constexpr int member_constexpr() { return 0; } // const in C++11
|
||||
constexpr int member_const_constexpr() const { return 0; }
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user