Switch to C++20

Bump the C++ standard version to C++20 in all the build files.

Put a designated initializer in a core Tint transform that is used on
all platforms as a smoke test.

Bug: 343500108
Change-Id: I6fdd7fbce3a5ff31b36a619f4de63f06dfab19c2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/235814
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: James Price <jrprice@google.com>
diff --git a/.bazelrc b/.bazelrc
index 7bcb652..1fa13dd 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -31,4 +31,4 @@
 #       There is no support for Dawn targets at this time                      #
 ################################################################################
 
-build --cxxopt='-std=c++17'
+build --cxxopt='-std=c++20'
diff --git a/build_overrides/partition_alloc.gni b/build_overrides/partition_alloc.gni
index 3c01fdb..f778bc2 100644
--- a/build_overrides/partition_alloc.gni
+++ b/build_overrides/partition_alloc.gni
@@ -64,7 +64,5 @@
 raw_ptr_zero_on_move_default = true
 raw_ptr_zero_on_destruct_default = false
 
-# Allow embedders to opt-out of C++20 build which is set as default.
-#
-# Dawn still uses C++17 only, because of Skia.
-assert_cpp20_default = false
+# Dawn requires C++20.
+assert_cpp20_default = true
diff --git a/docs/quickstart-cmake.md b/docs/quickstart-cmake.md
index 113aa18..29b74f1 100644
--- a/docs/quickstart-cmake.md
+++ b/docs/quickstart-cmake.md
@@ -6,7 +6,7 @@
 ## Prerequisites
 
 - A compatible platform (e.g. Windows, macOS, Linux, etc.). Most platforms are fully supported.
-- A compatible C++ compiler supporting at least C++17. Most major compilers are supported.
+- A compatible C++ compiler supporting at least C++20. Most major compilers are supported.
 - Git for interacting with the Dawn source code repository.
 - CMake for building your project and Dawn. Dawn supports CMake 3.16+.
 
diff --git a/docs/tint/style_guide.md b/docs/tint/style_guide.md
index 25e9146..b390e47 100644
--- a/docs/tint/style_guide.md
+++ b/docs/tint/style_guide.md
@@ -47,7 +47,7 @@
 
 ## Compiler support
 
-Tint requires C++17.
+Tint requires C++20.
 
 Tint uses the Chromium build system and will stay synchronized with that system.
 Compiler configurations beyond that baseline is on a best-effort basis.
diff --git a/src/cmake/DawnCompilerChecks.cmake b/src/cmake/DawnCompilerChecks.cmake
index d8bbe42..3129b10 100644
--- a/src/cmake/DawnCompilerChecks.cmake
+++ b/src/cmake/DawnCompilerChecks.cmake
@@ -25,9 +25,9 @@
 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-# Make sure we have C++17 enabled.
+# Make sure we have C++20 enabled.
 # Needed to make sure libraries and executables not built by the
-# dawn_add_library still have the C++17 compiler flags enabled
-set(CMAKE_CXX_STANDARD 17)
+# dawn_add_library still have the C++20 compiler flags enabled
+set(CMAKE_CXX_STANDARD 20)
 set(CMAKE_CXX_STANDARD_REQUIRED True)
 set(CMAKE_CXX_EXTENSIONS False)
diff --git a/src/tint/CMakeLists.txt b/src/tint/CMakeLists.txt
index 47daaf8..88f6828 100644
--- a/src/tint/CMakeLists.txt
+++ b/src/tint/CMakeLists.txt
@@ -196,6 +196,8 @@
         )
       endif()
     endif()
+
+    target_compile_definitions(${TARGET} INTERFACE "NOMINMAX")
   endif()
 
   if(TINT_RANDOMIZE_HASHES)
diff --git a/src/tint/flags.bzl b/src/tint/flags.bzl
index b607cf8..48f3ed3 100644
--- a/src/tint/flags.bzl
+++ b/src/tint/flags.bzl
@@ -68,7 +68,7 @@
 COPTS = [
     "-fno-rtti",
     "-fno-exceptions",
-    "--std=c++17",
+    "--std=c++20",
 ] + select({
     "//src/tint:tint_build_glsl_writer_true": [ "-DTINT_BUILD_GLSL_WRITER" ],
     "//conditions:default": [],
diff --git a/src/tint/lang/core/io_attributes.h b/src/tint/lang/core/io_attributes.h
index e15da0d..8aac0b6 100644
--- a/src/tint/lang/core/io_attributes.h
+++ b/src/tint/lang/core/io_attributes.h
@@ -39,15 +39,15 @@
 /// Attributes that can be applied to an object that will be used for shader IO.
 struct IOAttributes {
     /// The value of a `@location` attribute.
-    std::optional<uint32_t> location;
+    std::optional<uint32_t> location = std::nullopt;
     /// The value of a `@blend_src` attribute.
-    std::optional<uint32_t> blend_src;
+    std::optional<uint32_t> blend_src = std::nullopt;
     /// The value of a `@color` attribute.
-    std::optional<uint32_t> color;
+    std::optional<uint32_t> color = std::nullopt;
     /// The value of a `@builtin` attribute.
-    std::optional<core::BuiltinValue> builtin;
+    std::optional<core::BuiltinValue> builtin = std::nullopt;
     /// The values of a `@interpolate` attribute.
-    std::optional<core::Interpolation> interpolation;
+    std::optional<core::Interpolation> interpolation = std::nullopt;
     /// True if the object is annotated with `@invariant`.
     bool invariant = false;
 };
diff --git a/src/tint/lang/core/ir/transform/shader_io.cc b/src/tint/lang/core/ir/transform/shader_io.cc
index d936e46..c73fd65 100644
--- a/src/tint/lang/core/ir/transform/shader_io.cc
+++ b/src/tint/lang/core/ir/transform/shader_io.cc
@@ -110,12 +110,7 @@
             vertex_point_size_index =
                 backend->AddOutput(ir.symbols.New("vertex_point_size"), ty.f32(),
                                    core::IOAttributes{
-                                       /* location */ std::nullopt,
-                                       /* index */ std::nullopt,
-                                       /* color */ std::nullopt,
-                                       /* builtin */ core::BuiltinValue::kPointSize,
-                                       /* interpolation */ std::nullopt,
-                                       /* invariant */ false,
+                                       .builtin = core::BuiltinValue::kPointSize,
                                    });
         }