[clang] [Clang][Sema] Fix type of enumerators in incomplete enumerations (PR #84068)

2024-03-12 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman closed https://github.com/llvm/llvm-project/pull/84068 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][Sema] Fix type of enumerators in incomplete enumerations (PR #84068)

2024-03-11 Thread via cfe-commits
@@ -1,12 +1,19 @@ // RUN: %clang_cc1 -x c -fsyntax-only -verify -Wenum-compare -Wno-unused-comparison %s // RUN: %clang_cc1 -x c++ -fsyntax-only -verify -Wenum-compare -Wno-unused-comparison %s +// In C enumerators (i.e enumeration constants) have type int (until C23). In o

[clang] [Clang][Sema] Fix type of enumerators in incomplete enumerations (PR #84068)

2024-03-11 Thread via cfe-commits
@@ -1,12 +1,19 @@ // RUN: %clang_cc1 -x c -fsyntax-only -verify -Wenum-compare -Wno-unused-comparison %s // RUN: %clang_cc1 -x c++ -fsyntax-only -verify -Wenum-compare -Wno-unused-comparison %s +// In C enumerators (i.e enumeration constants) have type int (until C23). In o

[clang] [Clang][Sema] Fix type of enumerators in incomplete enumerations (PR #84068)

2024-03-11 Thread via cfe-commits
https://github.com/Kupa-Martin updated https://github.com/llvm/llvm-project/pull/84068 >From cc6a1329761a8fa5ae0b9f51ef8b7f839d5edff2 Mon Sep 17 00:00:00 2001 From: 44-2-Kupa-Martin Date: Tue, 5 Mar 2024 17:21:02 -0300 Subject: [PATCH] [Clang][Sema] Fix type of enumerators in incomplete enumer

[clang] [Clang][Sema] Fix type of enumerators in incomplete enumerations (PR #84068)

2024-03-11 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman approved this pull request. Aside from some formatting issues, this LGTM. Once you push up a fix for the formatting, I'll land. Thank you! https://github.com/llvm/llvm-project/pull/84068 ___ cfe-commits mailing list cfe

[clang] [Clang][Sema] Fix type of enumerators in incomplete enumerations (PR #84068)

2024-03-11 Thread Aaron Ballman via cfe-commits
@@ -1,12 +1,19 @@ // RUN: %clang_cc1 -x c -fsyntax-only -verify -Wenum-compare -Wno-unused-comparison %s // RUN: %clang_cc1 -x c++ -fsyntax-only -verify -Wenum-compare -Wno-unused-comparison %s +// In C enumerators (i.e enumeration constants) have type int (until C23). In o

[clang] [Clang][Sema] Fix type of enumerators in incomplete enumerations (PR #84068)

2024-03-11 Thread Aaron Ballman via cfe-commits
@@ -1,12 +1,19 @@ // RUN: %clang_cc1 -x c -fsyntax-only -verify -Wenum-compare -Wno-unused-comparison %s // RUN: %clang_cc1 -x c++ -fsyntax-only -verify -Wenum-compare -Wno-unused-comparison %s +// In C enumerators (i.e enumeration constants) have type int (until C23). In o

[clang] [Clang][Sema] Fix type of enumerators in incomplete enumerations (PR #84068)

2024-03-11 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman edited https://github.com/llvm/llvm-project/pull/84068 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][Sema] Fix type of enumerators in incomplete enumerations (PR #84068)

2024-03-11 Thread via cfe-commits
Kupa-Martin wrote: > > @shafik We dont have a dedicated cpp test for this. I can add one if you > > want, but clang/test/Sema/warn-compare-enum-types-mismatch.c runs clang > > both on C and C++ mode, so I didnt think it necessary. > > I think we just a bug that demonstrates this issue: #84712

[clang] [Clang][Sema] Fix type of enumerators in incomplete enumerations (PR #84068)

2024-03-11 Thread via cfe-commits
https://github.com/Kupa-Martin edited https://github.com/llvm/llvm-project/pull/84068 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][Sema] Fix type of enumerators in incomplete enumerations (PR #84068)

2024-03-11 Thread via cfe-commits
https://github.com/Kupa-Martin updated https://github.com/llvm/llvm-project/pull/84068 >From 57538a2e2b9446cf692d11386b3560225eb86ce4 Mon Sep 17 00:00:00 2001 From: 44-2-Kupa-Martin Date: Tue, 5 Mar 2024 17:21:02 -0300 Subject: [PATCH] [Clang][Sema] Fix type of enumerators in incomplete enumer

[clang] [Clang][Sema] Fix type of enumerators in incomplete enumerations (PR #84068)

2024-03-11 Thread via cfe-commits
Sirraide wrote: Regarding #84712: From what I can tell, the behaviour of cases such as ```c++ enum e1 { a }; enum e2 { b = a }; ``` has changed between C++11 and C++14 (at least the wording is different starting with C++14; there may be some other section that states the same for C++11, but I c

[clang] [Clang][Sema] Fix type of enumerators in incomplete enumerations (PR #84068)

2024-03-11 Thread Shafik Yaghmour via cfe-commits
shafik wrote: > @shafik We dont have a dedicated cpp test for this. I can add one if you > want, but clang/test/Sema/warn-compare-enum-types-mismatch.c runs clang both > on C and C++ mode, so I didnt think it necessary. I think we just a bug that demonstrates this issue: https://github.com/ll

[clang] [Clang][Sema] Fix type of enumerators in incomplete enumerations (PR #84068)

2024-03-08 Thread via cfe-commits
Kupa-Martin wrote: @shafik We dont have a dedicated cpp test for this. I can add one if you want, but clang/test/Sema/warn-compare-enum-types-mismatch.c runs clang both on C and C++ mode, so I didnt think it necessary. https://github.com/llvm/llvm-project/pull/84068 ___

[clang] [Clang][Sema] Fix type of enumerators in incomplete enumerations (PR #84068)

2024-03-08 Thread Shafik Yaghmour via cfe-commits
@@ -6,7 +6,9 @@ typedef enum EnumA { } EnumA; enum EnumB { - B + B, shafik wrote: I think what I was asking, was do we have an equivalent C++ test that verifies in a `.cpp` file that we also do not obtain a diagnostic for this. https://github.com/llvm/llv

[clang] [Clang][Sema] Fix type of enumerators in incomplete enumerations (PR #84068)

2024-03-08 Thread Shafik Yaghmour via cfe-commits
shafik wrote: > So I believe: > > ``` > typedef enum EnumA { > A > } EnumA; > > enum EnumB { > B, > B1 = 1, > B2 = A == B1 > }; > ``` > > is not an enum compare warning in C++ because `B1` doesn't have an > enumeration type due to the enumeration not being fully-defined, and is not >

[clang] [Clang][Sema] Fix type of enumerators in incomplete enumerations (PR #84068)

2024-03-08 Thread via cfe-commits
@@ -6,7 +6,9 @@ typedef enum EnumA { } EnumA; enum EnumB { - B + B, Kupa-Martin wrote: done https://github.com/llvm/llvm-project/pull/84068 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.ll

[clang] [Clang][Sema] Fix type of enumerators in incomplete enumerations (PR #84068)

2024-03-08 Thread via cfe-commits
@@ -264,11 +264,14 @@ namespace { } QualType Expr::getEnumCoercedType(const ASTContext &Ctx) const { - if (isa(this->getType())) -return this->getType(); - else if (const auto *ECD = this->getEnumConstantDecl()) -return Ctx.getTypeDeclType(cast(ECD->getDeclContext())

[clang] [Clang][Sema] Fix type of enumerators in incomplete enumerations (PR #84068)

2024-03-08 Thread via cfe-commits
https://github.com/Kupa-Martin updated https://github.com/llvm/llvm-project/pull/84068 >From 4bbd5cf7eb1eeeaba8eed2ac4aba76cdbbcc671f Mon Sep 17 00:00:00 2001 From: 44-2-Kupa-Martin Date: Tue, 5 Mar 2024 17:21:02 -0300 Subject: [PATCH] [Clang][Sema] Fix type of enumerators in incomplete enumer

[clang] [Clang][Sema] Fix type of enumerators in incomplete enumerations (PR #84068)

2024-03-08 Thread via cfe-commits
Kupa-Martin wrote: > not an enum compare warning in C++ because `B1` doesn't have an enumeration > type due to the enumeration not being fully-defined, and is not an enum > compare warning in C because `A` has type `int` (due to p15) and `B1` has > type `int` (due to p12). Yes, you are correc

[clang] [Clang][Sema] Fix type of enumerators in incomplete enumerations (PR #84068)

2024-03-08 Thread Aaron Ballman via cfe-commits
@@ -6,7 +6,9 @@ typedef enum EnumA { } EnumA; enum EnumB { - B + B, AaronBallman wrote: It might be good to capture some of what I wrote in the review summary as a comment here so it's clear why this is correct in both C and C++. https://github.com/llvm/l

[clang] [Clang][Sema] Fix type of enumerators in incomplete enumerations (PR #84068)

2024-03-08 Thread Aaron Ballman via cfe-commits
@@ -264,11 +264,14 @@ namespace { } QualType Expr::getEnumCoercedType(const ASTContext &Ctx) const { - if (isa(this->getType())) -return this->getType(); - else if (const auto *ECD = this->getEnumConstantDecl()) -return Ctx.getTypeDeclType(cast(ECD->getDeclContext())

[clang] [Clang][Sema] Fix type of enumerators in incomplete enumerations (PR #84068)

2024-03-08 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman edited https://github.com/llvm/llvm-project/pull/84068 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][Sema] Fix type of enumerators in incomplete enumerations (PR #84068)

2024-03-08 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman approved this pull request. Hmm, the rules are different between C and C++, but I think we may be okay. In C++: https://eel.is/c++draft/enum#dcl.enum-5.sentence-6 Following the closing brace of an enum-specifier, each enumerator has the type of its enumeration.

[clang] [Clang][Sema] Fix type of enumerators in incomplete enumerations (PR #84068)

2024-03-07 Thread via cfe-commits
Kupa-Martin wrote: > Should we also have a C++ test for this fix? clang/test/Sema/warn-compare-enum-types-mismatch.c should cover both C and C++. Or do you mean some other kind of test? https://github.com/llvm/llvm-project/pull/84068 ___ cfe-commits

[clang] [Clang][Sema] Fix type of enumerators in incomplete enumerations (PR #84068)

2024-03-07 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik commented: Should we also have a C++ test for this fix? https://github.com/llvm/llvm-project/pull/84068 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][Sema] Fix type of enumerators in incomplete enumerations (PR #84068)

2024-03-06 Thread Erich Keane via cfe-commits
erichkeane wrote: > > > Also, this probably needs a release note. > > > > > > If you want I'll add one but this bug has been on main no longer than a > > week, so I didnt think it would be necessary. > > I see. Yeah, I don’t think we really need one if the bug was introduced and > fixed in t

[clang] [Clang][Sema] Fix type of enumerators in incomplete enumerations (PR #84068)

2024-03-05 Thread via cfe-commits
Sirraide wrote: > > Also, this probably needs a release note. > > If you want I'll add one but this bug has been on main no longer than a week, > so I didnt think it would be necessary. I see. Yeah, I don’t think we really need one if the bug was introduced and fixed in the same version. htt

[clang] [Clang][Sema] Fix type of enumerators in incomplete enumerations (PR #84068)

2024-03-05 Thread via cfe-commits
@@ -264,10 +264,13 @@ namespace { } QualType Expr::getEnumCoercedType(const ASTContext &Ctx) const { - if (isa(this->getType())) + if (isa(this->getType())) { return this->getType(); - else if (const auto *ECD = this->getEnumConstantDecl()) -return Ctx.getTypeDeclT

[clang] [Clang][Sema] Fix type of enumerators in incomplete enumerations (PR #84068)

2024-03-05 Thread via cfe-commits
https://github.com/Kupa-Martin updated https://github.com/llvm/llvm-project/pull/84068 >From 92c0ebc1fa419404dfa8c2497248cc35c2644c5b Mon Sep 17 00:00:00 2001 From: 44-2-Kupa-Martin Date: Tue, 5 Mar 2024 17:21:02 -0300 Subject: [PATCH] [Clang][Sema] Fix type of enumerators in incomplete enumer

[clang] [Clang][Sema] Fix type of enumerators in incomplete enumerations (PR #84068)

2024-03-05 Thread via cfe-commits
Kupa-Martin wrote: > Also, this probably needs a release note. If you want I'll add one but this bug has been on main no longer than a week, so I didnt think it would be necessary. https://github.com/llvm/llvm-project/pull/84068 ___ cfe-commits maili

[clang] [Clang][Sema] Fix type of enumerators in incomplete enumerations (PR #84068)

2024-03-05 Thread via cfe-commits
Sirraide wrote: Also, this probably needs a release note. https://github.com/llvm/llvm-project/pull/84068 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][Sema] Fix type of enumerators in incomplete enumerations (PR #84068)

2024-03-05 Thread via cfe-commits
@@ -264,10 +264,13 @@ namespace { } QualType Expr::getEnumCoercedType(const ASTContext &Ctx) const { - if (isa(this->getType())) + if (isa(this->getType())) { return this->getType(); - else if (const auto *ECD = this->getEnumConstantDecl()) -return Ctx.getTypeDeclT

[clang] [Clang][Sema] Fix type of enumerators in incomplete enumerations (PR #84068)

2024-03-05 Thread via cfe-commits
Kupa-Martin wrote: @erichkeane I cant add the previous reviewers myself, could you do it for me please? https://github.com/llvm/llvm-project/pull/84068 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/list

[clang] [Clang][Sema] Fix type of enumerators in incomplete enumerations (PR #84068)

2024-03-05 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang Author: None (Kupa-Martin) Changes Enumerators dont have the type of their enumeration before the closing brace. In these cases Expr::getEnumCoercedType() incorrectly returned the enumeration type. Introduced in PR #81418 --- Full diff: https:/

[clang] [Clang][Sema] Fix type of enumerators in incomplete enumerations (PR #84068)

2024-03-05 Thread via cfe-commits
https://github.com/Kupa-Martin created https://github.com/llvm/llvm-project/pull/84068 Enumerators dont have the type of their enumeration before the closing brace. In these cases Expr::getEnumCoercedType() incorrectly returned the enumeration type. Introduced in PR #81418 >From bc9f93713a07