[all-commits] [llvm/llvm-project] e294ec: BPF: fix enum value 0 issue for __builtin_preserve...
yonghong-song via All-commits
all-commits at lists.llvm.org
Mon May 3 17:45:46 PDT 2021
Branch: refs/heads/release/12.x
Home: https://github.com/llvm/llvm-project
Commit: e294ece42d85191875782ed05cb607451f493944
https://github.com/llvm/llvm-project/commit/e294ece42d85191875782ed05cb607451f493944
Author: Yonghong Song <yhs at fb.com>
Date: 2021-05-03 (Mon, 03 May 2021)
Changed paths:
M clang/lib/Sema/SemaChecking.cpp
M clang/test/CodeGen/builtins-bpf-preserve-field-info-4.c
Log Message:
-----------
BPF: fix enum value 0 issue for __builtin_preserve_enum_value()
Lorenz Bauer reported that the following code will have
compilation error for bpf target:
enum e { TWO };
bpf_core_enum_value_exists(enum e, TWO);
The clang emitted the following error message:
__builtin_preserve_enum_value argument 1 invalid
In SemaChecking, an expression like "*(enum NAME)1" will have
cast kind CK_IntegralToPointer, but "*(enum NAME)0" will have
cast kind CK_NullToPointer. Current implementation only permits
CK_IntegralToPointer, missing enum value 0 case.
This patch permits CK_NullToPointer cast kind and
the above test case can pass now.
Differential Revision: https://reviews.llvm.org/D97659
(cherry picked from commit 283db5f0837d55f91242812003adf6e189ba743e)
More information about the All-commits
mailing list