[Tizen] Fix build issues with clang18 accepted/tizen/unified/toolchain/20240610.173352 accepted/tizen/unified/x/20240610.223913 accepted/tizen/unified/x/asan/20240625.092715
authorHyungju Lee <leee.lee@samsung.com>
Mon, 10 Jun 2024 11:13:26 +0000 (20:13 +0900)
committer이형주/MDE Lab(SR)/삼성전자 <leee.lee@samsung.com>
Mon, 10 Jun 2024 11:19:07 +0000 (20:19 +0900)
eng/native/configurecompiler.cmake
src/shared/minipal/getexepath.h
src/shared/pal/src/file/path.cpp
src/shared/pal/src/include/pal/palinternal.h

index 0be4937c7f8d467a5ebdf487c924105163d4de33..e4d96c1e6e7de7470be61c5b760c21977a89e035 100644 (file)
@@ -549,6 +549,11 @@ if (CLR_CMAKE_HOST_UNIX)
     add_compile_options(-Wimplicit-fallthrough)
   endif()
 
+  # VLAs are non standard in C++, aren't available on Windows and
+  # are a warning by default since clang 18.
+  # For consistency, enable warnings for all compiler versions.
+  add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wvla>)
+
   #These seem to indicate real issues
   add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-invalid-offsetof>)
 
@@ -591,6 +596,9 @@ if (CLR_CMAKE_HOST_UNIX)
     # other clang 16.0 suppressions
     add_compile_options(-Wno-single-bit-bitfield-constant-conversion)
     add_compile_options(-Wno-cast-function-type-strict)
+
+    # clang 18.1 supressions
+    add_compile_options(-Wno-switch-default)
   else()
     add_compile_options(-Wno-uninitialized)
     add_compile_options(-Wno-strict-aliasing)
index a5e12e08a25a006ba4125c4e0f486d1ea7afb959..3c9ad5368ac422f45b27103b7e7fd2fbefee8346 100644 (file)
@@ -37,7 +37,7 @@ static inline char* minipal_getexepath(void)
         return NULL;
     }
 
-    char path_buf[path_length];
+    char* path_buf = (char*)alloca(path_length);
     if (_NSGetExecutablePath(path_buf, &path_length) != 0)
     {
         errno = EINVAL;
index edc9c6c0a6619bbbed9b2b9da097148ba68a88aa..469756e6ce65609e155b13177c3006bd5ec7b6d0 100644 (file)
@@ -401,8 +401,8 @@ GetTempPathW(
         return 0;
     }
 
-    char TempBuffer[nBufferLength > 0 ? nBufferLength : 1];
-    DWORD dwRetVal = GetTempPathA( nBufferLength, TempBuffer );
+    char* tempBuffer = (char*)alloca(nBufferLength > 0 ? nBufferLength : 1);
+    DWORD dwRetVal = GetTempPathA( nBufferLength, tempBuffer );
 
     if ( dwRetVal >= nBufferLength )
     {
@@ -413,7 +413,7 @@ GetTempPathW(
     else if ( dwRetVal != 0 )
     {
         /* Convert to wide. */
-        if ( 0 == MultiByteToWideChar( CP_ACP, 0, TempBuffer, -1,
+        if ( 0 == MultiByteToWideChar( CP_ACP, 0, tempBuffer, -1,
                                        lpBuffer, dwRetVal + 1 ) )
         {
             ASSERT( "An error occurred while converting the string to wide.\n" );
index 6b2622455067ac87e0a7d3d6569cf27107a477ec..0078c1c44f8a84510c790c39b26e0b83eba12ef0 100644 (file)
@@ -431,6 +431,7 @@ function_name() to call the system's implementation
 #undef va_start
 #undef va_end
 #undef va_copy
+#undef va_arg
 #undef stdin
 #undef stdout
 #undef stderr