[all-commits] [llvm/llvm-project] 8cfdd3: [clang] Fixes compile error that double colon oper...
Yonggang Luo via All-commits
all-commits at lists.llvm.org
Mon Dec 4 23:49:45 PST 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 8cfdd37088d662338ec85ac15721dddf3f6d8db6
https://github.com/llvm/llvm-project/commit/8cfdd37088d662338ec85ac15721dddf3f6d8db6
Author: Yonggang Luo <luoyonggang at gmail.com>
Date: 2023-12-05 (Tue, 05 Dec 2023)
Changed paths:
M clang/docs/ReleaseNotes.rst
M clang/lib/Headers/bmiintrin.h
Log Message:
-----------
[clang] Fixes compile error that double colon operator cannot resolve macro with parentheses. (#68618)
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 at gmail.com>
More information about the All-commits
mailing list