Skip to content

Commit

Permalink
[flang] Assert the Options fit into the storage bits (#126169)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmayer authored Feb 16, 2025
1 parent 26fc2e9 commit a7a0208
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion flang/include/flang/Support/LangOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ class LangOptions : public LangOptionsBase {
#define LANGOPT(Name, Bits, Default)
#define ENUM_LANGOPT(Name, Type, Bits, Default) \
Type get##Name() const { return static_cast<Type>(Name); } \
void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
void set##Name(Type Value) { \
assert(static_cast<unsigned>(Value) < (1u << Bits)); \
Name = static_cast<unsigned>(Value); \
}
#include "LangOptions.def"

/// Name of the IR file that contains the result of the OpenMP target
Expand Down

0 comments on commit a7a0208

Please sign in to comment.