[all-commits] [llvm/llvm-project] ca75ac: Diagnose unreachable generic selection associations
Aaron Ballman via All-commits
all-commits at lists.llvm.org
Tue May 10 08:16:13 PDT 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: ca75ac5f04f269def97e6844c2f5c9596b29c84c
https://github.com/llvm/llvm-project/commit/ca75ac5f04f269def97e6844c2f5c9596b29c84c
Author: Aaron Ballman <aaron at aaronballman.com>
Date: 2022-05-10 (Tue, 10 May 2022)
Changed paths:
M clang/docs/ReleaseNotes.rst
M clang/include/clang/Basic/DiagnosticGroups.td
M clang/include/clang/Basic/DiagnosticSemaKinds.td
M clang/lib/Sema/SemaExpr.cpp
M clang/test/Sema/generic-selection.c
Log Message:
-----------
Diagnose unreachable generic selection associations
The controlling expression of a _Generic selection expression undergoes
lvalue conversion, array conversion, and function conversion before
picking the association. This means that array types, function types,
and qualified types are all unreachable code if they're used as an
association. I've been caught by this twice in the past few months and
I figure that if a WG14 member can't seem to remember this rule, users
are also likely to struggle with it. So this adds an on-by-default
unreachable code diagnostic for generic selection expression
associations.
Note, we don't have to worry about function types as those are already
a constraint violation which generates an error.
Differential Revision: https://reviews.llvm.org/D125259
More information about the All-commits
mailing list