[clang] [clang][Interp] Handle CXXScalarValueInitExprs (PR #67147)

Shafik Yaghmour via cfe-commits cfe-commits at lists.llvm.org
Sat Sep 23 12:35:13 PDT 2023


Timm =?utf-8?q?B=C3=A4der?= <tbaeder at redhat.com>
Message-ID:
In-Reply-To: <llvm/llvm-project/pull/67147/clang at github.com>


================
@@ -31,6 +31,28 @@ static_assert(b, "");
 constexpr int one = true;
 static_assert(one == 1, "");
 
+constexpr bool b2 = bool();
+static_assert(!b2, "");
+
+namespace ScalarTypes {
+  constexpr int ScalarInitInt = int();
+  static_assert(ScalarInitInt == 0, "");
+  constexpr float ScalarInitFloat = float();
+  static_assert(ScalarInitFloat == 0.0f, "");
+
+  static_assert(decltype(nullptr)() == nullptr, "");
+
+  template<typename T>
+  constexpr T getScalar() { return T(); }
+
+  static_assert(getScalar<const int>() == 0, "");
+  static_assert(getScalar<const double>() == 0.0, "");
+
+  static_assert(getScalar<void*>() == nullptr, "");
+  static_assert(getScalar<void(*)(void)>() == nullptr, "");
+  /// FIXME: Member pointers.
----------------
shafik wrote:

and enumeration types

https://github.com/llvm/llvm-project/pull/67147


More information about the cfe-commits mailing list