SquallATF wrote:

Hi @a-tarasyuk 

It seems this PR introduces a regression when compiling Windows projects using 
ATL (Active Template Library). Since this patch was landed, Clang now fails to 
compile standard ATL headers (like atlcore.h and atlcomcli.h) with the 
following error:

```
In file included from C:\Program Files\Microsoft Visual 
Studio\18\Community\VC/Tools/MSVC/14.50.35717/atlmfc/include/atlbase.h:75:
C:\Program Files\Microsoft Visual 
Studio\18\Community\VC/Tools/MSVC/14.50.35717/atlmfc/include/atlcomcli.h(1853,13):
 error:
      'selectany' can only be applied to variables with external linkage
 1853 | __declspec( selectany ) char VARIANT::* const CVarTypeInfo< char 
>::pmField = &VARIANT::cVal;
      |             ^
C:\Program Files\Microsoft Visual 
Studio\18\Community\VC/Tools/MSVC/14.50.35717/atlmfc/include/atlcomcli.h(1863,13):
 error:
      'selectany' can only be applied to variables with external linkage
 1863 | __declspec( selectany ) unsigned char VARIANT::* const CVarTypeInfo< 
unsigned char >::pmField = &VARIANT::bVal;
      |             ^
C:\Program Files\Microsoft Visual 
Studio\18\Community\VC/Tools/MSVC/14.50.35717/atlmfc/include/atlcomcli.h(1873,13):
 error:
      'selectany' can only be applied to variables with external linkage
 1873 | __declspec( selectany ) char* VARIANT::* const CVarTypeInfo< char* 
>::pmField = &VARIANT::pcVal;
      |             ^
C:\Program Files\Microsoft Visual 
Studio\18\Community\VC/Tools/MSVC/14.50.35717/atlmfc/include/atlcomcli.h(1883,13):
 error:
      'selectany' can only be applied to variables with external linkage
 1883 | __declspec( selectany ) unsigned char* VARIANT::* const CVarTypeInfo< 
unsigned char* >::pmField = &VARIANT::pbVal;
      |             ^
C:\Program Files\Microsoft Visual 
Studio\18\Community\VC/Tools/MSVC/14.50.35717/atlmfc/include/atlcomcli.h(1893,13):
 error:
      'selectany' can only be applied to variables with external linkage
 1893 | __declspec( selectany ) short VARIANT::* const CVarTypeInfo< short 
>::pmField = &VARIANT::iVal;
      |             ^
C:\Program Files\Microsoft Visual 
Studio\18\Community\VC/Tools/MSVC/14.50.35717/atlmfc/include/atlcomcli.h(1903,13):
 error:
      'selectany' can only be applied to variables with external linkage
 1903 | __declspec( selectany ) short* VARIANT::* const CVarTypeInfo< short* 
>::pmField = &VARIANT::piVal;
      |             ^
C:\Program Files\Microsoft Visual 
Studio\18\Community\VC/Tools/MSVC/14.50.35717/atlmfc/include/atlcomcli.h(1913,13):
 error:
      'selectany' can only be applied to variables with external linkage
 1913 | __declspec( selectany ) unsigned short VARIANT::* const CVarTypeInfo< 
unsigned short >::pmField = &VARIANT::uiVal;
      |             ^
C:\Program Files\Microsoft Visual 
Studio\18\Community\VC/Tools/MSVC/14.50.35717/atlmfc/include/atlcomcli.h(1924,13):
 error:
      'selectany' can only be applied to variables with external linkage
 1924 | __declspec( selectany ) unsigned short* VARIANT::* const CVarTypeInfo< 
unsigned short* >::pmField = &VARIA...
      |             ^
C:\Program Files\Microsoft Visual 
Studio\18\Community\VC/Tools/MSVC/14.50.35717/atlmfc/include/atlcomcli.h(1935,13):
 error:
      'selectany' can only be applied to variables with external linkage
 1935 | __declspec( selectany ) int VARIANT::* const CVarTypeInfo< int 
>::pmField = &VARIANT::intVal;
      |             ^
C:\Program Files\Microsoft Visual 
Studio\18\Community\VC/Tools/MSVC/14.50.35717/atlmfc/include/atlcomcli.h(1945,13):
 error:
      'selectany' can only be applied to variables with external linkage
 1945 | __declspec( selectany ) int* VARIANT::* const CVarTypeInfo< int* 
>::pmField = &VARIANT::pintVal;
      |             ^
C:\Program Files\Microsoft Visual 
Studio\18\Community\VC/Tools/MSVC/14.50.35717/atlmfc/include/atlcomcli.h(1955,13):
 error:
      'selectany' can only be applied to variables with external linkage
 1955 | __declspec( selectany ) unsigned int VARIANT::* const CVarTypeInfo< 
unsigned int >::pmField = &VARIANT::uintVal;
      |             ^
C:\Program Files\Microsoft Visual 
Studio\18\Community\VC/Tools/MSVC/14.50.35717/atlmfc/include/atlcomcli.h(1965,13):
 error:
      'selectany' can only be applied to variables with external linkage
 1965 | __declspec( selectany ) unsigned int* VARIANT::* const CVarTypeInfo< 
unsigned int* >::pmField = &VARIANT::...
      |             ^
C:\Program Files\Microsoft Visual 
Studio\18\Community\VC/Tools/MSVC/14.50.35717/atlmfc/include/atlcomcli.h(1975,13):
 error:
      'selectany' can only be applied to variables with external linkage
 1975 | __declspec( selectany ) long VARIANT::* const CVarTypeInfo< long 
>::pmField = &VARIANT::lVal;
      |             ^
C:\Program Files\Microsoft Visual 
Studio\18\Community\VC/Tools/MSVC/14.50.35717/atlmfc/include/atlcomcli.h(1985,13):
 error:
      'selectany' can only be applied to variables with external linkage
 1985 | __declspec( selectany ) long* VARIANT::* const CVarTypeInfo< long* 
>::pmField = &VARIANT::plVal;
      |             ^
C:\Program Files\Microsoft Visual 
Studio\18\Community\VC/Tools/MSVC/14.50.35717/atlmfc/include/atlcomcli.h(1995,13):
 error:
      'selectany' can only be applied to variables with external linkage
 1995 | __declspec( selectany ) unsigned long VARIANT::* const CVarTypeInfo< 
unsigned long >::pmField = &VARIANT::ulVal;
      |             ^
C:\Program Files\Microsoft Visual 
Studio\18\Community\VC/Tools/MSVC/14.50.35717/atlmfc/include/atlcomcli.h(2005,13):
 error:
      'selectany' can only be applied to variables with external linkage
 2005 | __declspec( selectany ) unsigned long* VARIANT::* const CVarTypeInfo< 
unsigned long* >::pmField = &VARIANT...
      |             ^
C:\Program Files\Microsoft Visual 
Studio\18\Community\VC/Tools/MSVC/14.50.35717/atlmfc/include/atlcomcli.h(2015,13):
 error:
      'selectany' can only be applied to variables with external linkage
 2015 | __declspec( selectany ) __int64 VARIANT::* const CVarTypeInfo< __int64 
>::pmField = &VARIANT::llVal;
      |             ^
C:\Program Files\Microsoft Visual 
Studio\18\Community\VC/Tools/MSVC/14.50.35717/atlmfc/include/atlcomcli.h(2025,13):
 error:
      'selectany' can only be applied to variables with external linkage
 2025 | __declspec( selectany ) __int64* VARIANT::* const CVarTypeInfo< 
__int64* >::pmField = &VARIANT::pllVal;
      |             ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
```

Specifically, ATL defines many static members and template constants using 
__declspec(selectany) that Clang now rejects. For example:
```c++
__declspec(selectany) bool CAtlBaseModule::m_bInitFailed = false;
```

https://github.com/llvm/llvm-project/pull/189641
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to