[all-commits] [llvm/llvm-project] cf8fd2: [C] Make (c ? e1 : e2) noreturn only if both e1 an...
Fangrui Song via All-commits
all-commits at lists.llvm.org
Thu Jan 5 14:36:49 PST 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: cf8fd210a35c8e93136cb8edc5c6a2e818dc1b1d
https://github.com/llvm/llvm-project/commit/cf8fd210a35c8e93136cb8edc5c6a2e818dc1b1d
Author: Fangrui Song <i at maskray.me>
Date: 2023-01-05 (Thu, 05 Jan 2023)
Changed paths:
M clang/docs/ReleaseNotes.rst
M clang/include/clang/AST/ASTContext.h
M clang/lib/AST/ASTContext.cpp
M clang/lib/Sema/SemaExpr.cpp
M clang/test/CodeGen/attr-noreturn.c
Log Message:
-----------
[C] Make (c ? e1 : e2) noreturn only if both e1 and e2 are noreturn
In C mode, if e1 has __attribute__((noreturn)) but e2 doesn't, `(c ? e1 : e2)`
is incorrectly noreturn and Clang codegen produces `unreachable`
which may lead to miscompiles (see [1] `gawk/support/dfa.c`).
This problem has been known since
8c6b56f39d967347f28dd9c93f1cffddf6d7e4cd (2010) or earlier.
Fix this by making the result type noreturn only if both e1 and e2 are
noreturn, matching GCC.
`_Noreturn` and `[[noreturn]]` do not have the aforementioned problem.
Fix https://github.com/llvm/llvm-project/issues/59792 [1]
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D140868
More information about the All-commits
mailing list