Error message:
In file included from ../src/amd/addrlib/src/core/addrobject.h:21: ../src/amd/addrlib/src/core/addrcommon.h:343:13: error: expected unqualified-id out = ::_tzcnt_u32(mask); ^ /usr/lib/llvm-15/lib/clang/15.0.6/include/bmiintrin.h:74:27: note: expanded from macro '_tzcnt_u32' #define _tzcnt_u32(a) (__tzcnt_u32((a)))
This is because both GCC/Clang doesn't support compiling the following code:
#ifdef _MSC_VER #include <intrin.h> #else #include <x86intrin.h> #endif int f(int a) { return ::(_tzcnt_u32)(a); }
This is because the return statement expects an expression or braced init list: http://eel.is/c++draft/stmt.jump#general-1 but we really only need to care about the expression form (there's no braces in sight).
Grammatically, the leading :: will parse as a qualified-id because it matches the production for nested-name-specifier: http://eel.is/c++draft/expr.prim.id.qual#nt:qualified-id
That needs to be followed by an unqualified-id (http://eel.is/c++draft/expr.prim.id.unqual#nt:unqualified-id), but the open paren does not match any of the grammar productions, so this is a syntax error.
Closes: https://github.com/llvm/llvm-project/issues/64467
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>