Patch uPB for newer versions of clang.
This patches in
https://github.com/protocolbuffers/upb/commit/21af7830ad5ff34798d7c5c8c70c30b450f6634e.
C standard is also changed to c11 as it now uses a c11 extension.
Test: bazel build @upb//:upb
Bug: 265864471
Change-Id: I16f07c412cd53cb4e9c15d519a152c704f2b52e3
diff --git a/third_party/upb/bazel/build_defs.bzl b/third_party/upb/bazel/build_defs.bzl
index b5bc64f..dc30a75 100644
--- a/third_party/upb/bazel/build_defs.bzl
+++ b/third_party/upb/bazel/build_defs.bzl
@@ -38,7 +38,7 @@
"-Wno-long-long",
])
_DEFAULT_COPTS.extend([
- "-std=c99",
+ "-std=c11",
"-pedantic",
"-Werror=pedantic",
"-Wall",
diff --git a/third_party/upb/upb/port_def.inc b/third_party/upb/upb/port_def.inc
index 92e4bf2..e355ace 100644
--- a/third_party/upb/upb/port_def.inc
+++ b/third_party/upb/upb/port_def.inc
@@ -92,7 +92,11 @@
#define UPB_ALIGN_UP(size, align) (((size) + (align) - 1) / (align) * (align))
#define UPB_ALIGN_DOWN(size, align) ((size) / (align) * (align))
#define UPB_ALIGN_MALLOC(size) UPB_ALIGN_UP(size, UPB_MALLOC_ALIGN)
+#ifdef __clang__
+#define UPB_ALIGN_OF(type) _Alignof(type)
+#else
#define UPB_ALIGN_OF(type) offsetof (struct { char c; type member; }, member)
+#endif
/* Hints to the compiler about likely/unlikely branches. */
#if defined (__GNUC__) || defined(__clang__)