[clang] [C] Handle comma operator for implicit int->enum conversions (PR #138752)

2025-05-13 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: > @AaronBallman @erichkeane Apparently we used a clang version from July 2023 > to compile clang when the testcase failed. > > I made another try with a later build now and then I don't see the failure > anymore so perhaps something has been fixed. Or it just went hiding bu

[clang] [C] Handle comma operator for implicit int->enum conversions (PR #138752)

2025-05-12 Thread Mikael Holmén via cfe-commits
mikaelholmen wrote: @AaronBallman @erichkeane Apparently we used a clang version from July 2023 to compile clang when the testcase failed. I made another try with a later build now and then I don't see the failure anymore so perhaps something has been fixed. Or it just went hiding but then I

[clang] [C] Handle comma operator for implicit int->enum conversions (PR #138752)

2025-05-12 Thread Erich Keane via cfe-commits
erichkeane wrote: I've run it as well this way: ``` /local/home/ekeane/llvm-project/build/bin/clang -cc1 -internal-isystem /local/home/ekeane/llvm-project/build/lib/clang/21/include -nostdsysteminc -verify -Wno-unused -I /local/home/ekeane/llvm-project/clang/test/C/C99/Inputs /local/home/ekea

[clang] [C] Handle comma operator for implicit int->enum conversions (PR #138752)

2025-05-12 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: > Hi @AaronBallman > > I see that if I build clang with ASAN with this patch and run the testcase > `clang/test/C/C99/n590.c` it crashes and I see this > > ``` > AddressSanitizer:DEADLYSIGNAL > = > ==2063954==E

[clang] [C] Handle comma operator for implicit int->enum conversions (PR #138752)

2025-05-11 Thread Mikael Holmén via cfe-commits
mikaelholmen wrote: Hi @AaronBallman I see that if I build clang with ASAN with this patch and run the testcase ```clang/test/C/C99/n590.c``` it crashes and I see this ``` AddressSanitizer:DEADLYSIGNAL = ==2063954==ERROR: AddressSa

[clang] [C] Handle comma operator for implicit int->enum conversions (PR #138752)

2025-05-07 Thread Erich Keane via cfe-commits
@@ -12490,6 +12499,17 @@ static void AnalyzeImplicitConversions( (BO->getOpcode() == BO_And ? "&&" : "||")); S.Diag(BO->getBeginLoc(), diag::note_cast_operand_to_int); } +} else if (BO->isCommaOp() && !S.getLangOpts().CPlusPlus) { + ///

[clang] [C] Handle comma operator for implicit int->enum conversions (PR #138752)

2025-05-07 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman closed https://github.com/llvm/llvm-project/pull/138752 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [C] Handle comma operator for implicit int->enum conversions (PR #138752)

2025-05-07 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/138752 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,s

[clang] [C] Handle comma operator for implicit int->enum conversions (PR #138752)

2025-05-07 Thread Erich Keane via cfe-commits
https://github.com/erichkeane approved this pull request. 1 nit, else LGTM. https://github.com/llvm/llvm-project/pull/138752 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [C] Handle comma operator for implicit int->enum conversions (PR #138752)

2025-05-07 Thread Erich Keane via cfe-commits
https://github.com/erichkeane edited https://github.com/llvm/llvm-project/pull/138752 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [C] Handle comma operator for implicit int->enum conversions (PR #138752)

2025-05-07 Thread Erich Keane via cfe-commits
@@ -12490,6 +12499,17 @@ static void AnalyzeImplicitConversions( (BO->getOpcode() == BO_And ? "&&" : "||")); S.Diag(BO->getBeginLoc(), diag::note_cast_operand_to_int); } +} else if (BO->isCommaOp() && !S.getLangOpts().CPlusPlus) { + ///

[clang] [C] Handle comma operator for implicit int->enum conversions (PR #138752)

2025-05-07 Thread Aaron Ballman via cfe-commits
@@ -11647,6 +11647,29 @@ static void DiagnoseFloatingImpCast(Sema &S, Expr *E, QualType T, } } +static void CheckCommaOperand(Sema &S, Expr *E, QualType T, SourceLocation CC, + bool Check) { AaronBallman wrote: Renamed https:/

[clang] [C] Handle comma operator for implicit int->enum conversions (PR #138752)

2025-05-07 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/138752 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,s

[clang] [C] Handle comma operator for implicit int->enum conversions (PR #138752)

2025-05-06 Thread Erich Keane via cfe-commits
@@ -12464,7 +12487,7 @@ static void AnalyzeImplicitConversions( << OrigE->getSourceRange() << T->isBooleanType() << FixItHint::CreateReplacement(UO->getBeginLoc(), "!"); - if (const auto *BO = dyn_cast(SourceExpr)) + if (auto *BO = dyn_cast(SourceExpr)) -

[clang] [C] Handle comma operator for implicit int->enum conversions (PR #138752)

2025-05-06 Thread Erich Keane via cfe-commits
@@ -11647,6 +11647,29 @@ static void DiagnoseFloatingImpCast(Sema &S, Expr *E, QualType T, } } +static void CheckCommaOperand(Sema &S, Expr *E, QualType T, SourceLocation CC, + bool Check) { erichkeane wrote: `Check` is pretty

[clang] [C] Handle comma operator for implicit int->enum conversions (PR #138752)

2025-05-06 Thread Erich Keane via cfe-commits
@@ -11647,6 +11647,29 @@ static void DiagnoseFloatingImpCast(Sema &S, Expr *E, QualType T, } } +static void CheckCommaOperand(Sema &S, Expr *E, QualType T, SourceLocation CC, + bool Check) { + E = E->IgnoreParenImpCasts(); + AnalyzeImplicitCon

[clang] [C] Handle comma operator for implicit int->enum conversions (PR #138752)

2025-05-06 Thread Erich Keane via cfe-commits
@@ -11647,6 +11647,29 @@ static void DiagnoseFloatingImpCast(Sema &S, Expr *E, QualType T, } } +static void CheckCommaOperand(Sema &S, Expr *E, QualType T, SourceLocation CC, + bool Check) { + E = E->IgnoreParenImpCasts(); + AnalyzeImplicitCon

[clang] [C] Handle comma operator for implicit int->enum conversions (PR #138752)

2025-05-06 Thread Erich Keane via cfe-commits
@@ -11647,6 +11647,29 @@ static void DiagnoseFloatingImpCast(Sema &S, Expr *E, QualType T, } } +static void CheckCommaOperand(Sema &S, Expr *E, QualType T, SourceLocation CC, + bool Check) { + E = E->IgnoreParenImpCasts(); + AnalyzeImplicitCon

[clang] [C] Handle comma operator for implicit int->enum conversions (PR #138752)

2025-05-06 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang Author: Aaron Ballman (AaronBallman) Changes In C++, the type of an enumerator is the type of the enumeration, whereas in C, the type of the enumerator is 'int'. The type of a comma operator is the type of the right-hand operand, which means you

[clang] [C] Handle comma operator for implicit int->enum conversions (PR #138752)

2025-05-06 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman created https://github.com/llvm/llvm-project/pull/138752 In C++, the type of an enumerator is the type of the enumeration, whereas in C, the type of the enumerator is 'int'. The type of a comma operator is the type of the right-hand operand, which means you can