[Openmp-commits] [llvm] [libcxx] [clang-tools-extra] [clang] [lld] [mlir] [libc] [libunwind] [libcxxabi] [openmp] [flang] [C23] Implement N3018: The constexpr specifier for object definitions (PR #73099)

Mariya Podchishchaeva via Openmp-commits openmp-commits at lists.llvm.org
Thu Nov 30 02:11:52 PST 2023


================
@@ -0,0 +1,86 @@
+// RUN: %clang_cc1 -std=c2x -verify -triple x86_64 -pedantic -Wno-conversion -Wno-constant-conversion %s
+
+/* WG14 N3018: Full
+ * The constexpr specifier for object definitions
+ */
+
+#define ULLONG_MAX (__LONG_LONG_MAX__*2ULL+1ULL)
+#define UINT_MAX  (__INT_MAX__  *2U +1U)
+
+void Example0() {
+  constexpr unsigned int minusOne    = -1;
+  // expected-error at -1 {{constexpr initializer evaluates to -1 which is not exactly representable in type 'unsigned int'}}
+  constexpr unsigned int uint_max    = -1U;
+  constexpr double onethird          = 1.0/3.0;
+  constexpr double onethirdtrunc     = (double)(1.0/3.0);
+
+  constexpr char string[] = { "\xFF", };
----------------
Fznamznon wrote:

Added in `test/Sema/constexpr.c`.

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


More information about the Openmp-commits mailing list