Fznamznon wrote:
@cor3ntin , perhaps a dumb question, but
https://github.com/llvm/llvm-project/pull/77753 should only help in post C++20
modes since only there destructor can be `constexpr`. How about older versions?
Clang will still emit an error that the type from
cor3ntin wrote:
> @Fznamznon @cor3ntin So #77753 doesn't solve the problem of the enclosing
> class of an anonymous union not being literal when it should be, right?
It should actually, CF comments in that PR (I got your code working locally)
https://github.com/llvm/llvm-project/pull/78195
groundswellaudio wrote:
By looking at your tests on anonymous unions, I'd say that indirect fields are
handled correctly (perhaps they're not included in the fields range?, otherwise
the union-like class would not be considered literal) and that rather the
implicitly generated special member
cor3ntin wrote:
Looking at that again, i suspect I did not handle indirect fields properly.
I'll try to get to that. Sorry!
https://github.com/llvm/llvm-project/pull/78195
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
groundswellaudio wrote:
@Fznamznon
@cor3ntin
So https://github.com/llvm/llvm-project/pull/77753 doesn't solve the problem of
an anonymous union not being literal when it should be, right?
https://github.com/llvm/llvm-project/pull/78195
___
Fznamznon wrote:
> @groundswellaudio actually, that should be fixed by
> https://github.com/llvm/llvm-project/pull/77753
@Fznamznon Can you confirm?
Yes, it does make an error to go away. However the function `foo` from the
cor3ntin wrote:
@groundswellaudio actually, that should be fixed by
https://github.com/llvm/llvm-project/pull/77753
@Fznamznon Can you confirm?
https://github.com/llvm/llvm-project/pull/78195
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
cor3ntin wrote:
@groundswellaudio Thanks for letting me know. can you create a separate issue ?
https://github.com/llvm/llvm-project/pull/78195
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
groundswellaudio wrote:
Thanks for the fix @cor3ntin. There is still a problem however with
`std::optional`, which I think boils down to implicit destructor and anonymous
union :
```cpp
struct A {
A ();
~A();
};
template
struct opt
{
union {
char c;
T data;
};
https://github.com/cor3ntin closed
https://github.com/llvm/llvm-project/pull/78195
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/erichkeane approved this pull request.
https://github.com/llvm/llvm-project/pull/78195
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/cor3ntin updated
https://github.com/llvm/llvm-project/pull/78195
>From f354ca458c1fa3cebb375f756f1a87fcf0586c3c Mon Sep 17 00:00:00 2001
From: Corentin Jabot
Date: Mon, 15 Jan 2024 18:09:48 +0100
Subject: [PATCH 1/5] [Clang] Implement CWG2598: Union of non-literal types
A
@@ -1389,7 +1389,11 @@ bool CXXRecordDecl::isLiteral() const {
: hasTrivialDestructor()))
return false;
- if (isLambda() && !LangOpts.CPlusPlus17)
+ // Lambdas are literal types since C++17.
erichkeane wrote:
Hmm... this is
@@ -1389,7 +1389,11 @@ bool CXXRecordDecl::isLiteral() const {
: hasTrivialDestructor()))
return false;
- if (isLambda() && !LangOpts.CPlusPlus17)
+ // Lambdas are literal types since C++17.
cor3ntin wrote:
And aggregate
@@ -1389,7 +1389,11 @@ bool CXXRecordDecl::isLiteral() const {
: hasTrivialDestructor()))
return false;
- if (isLambda() && !LangOpts.CPlusPlus17)
+ // Lambdas are literal types since C++17.
erichkeane wrote:
So why is
https://github.com/cor3ntin updated
https://github.com/llvm/llvm-project/pull/78195
>From f354ca458c1fa3cebb375f756f1a87fcf0586c3c Mon Sep 17 00:00:00 2001
From: Corentin Jabot
Date: Mon, 15 Jan 2024 18:09:48 +0100
Subject: [PATCH 1/4] [Clang] Implement CWG2598: Union of non-literal types
A
@@ -1383,6 +1383,34 @@ void CXXRecordDecl::addedMember(Decl *D) {
}
}
+bool CXXRecordDecl::isLiteral() const {
+ const LangOptions = getLangOpts();
+ if (!(LangOpts.CPlusPlus20 ? hasConstexprDestructor()
+ : hasTrivialDestructor()))
+
cor3ntin wrote:
> Is this a potentially breaking change since we have expanded what types are
> considered literals and already existing code may observe this fix?
Some expression will become constant expressions and presumably that can be
SFINAE upon, but given that this is a DR, I don't
https://github.com/cor3ntin edited
https://github.com/llvm/llvm-project/pull/78195
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -208,3 +208,54 @@ namespace dr2565 { // dr2565: 16 open
#endif
}
+
+
+namespace dr2598 { // dr2598: 18
+#if __cplusplus >= 201103L
+struct NonLiteral {
+NonLiteral();
+};
+
+struct anonymous1 {
+union {} a;
+};
+static_assert(__is_literal(anonymous1), "");
+
@@ -1383,6 +1383,34 @@ void CXXRecordDecl::addedMember(Decl *D) {
}
}
+bool CXXRecordDecl::isLiteral() const {
+ const LangOptions = getLangOpts();
+ if (!(LangOpts.CPlusPlus20 ? hasConstexprDestructor()
+ : hasTrivialDestructor()))
+
https://github.com/cor3ntin updated
https://github.com/llvm/llvm-project/pull/78195
>From f354ca458c1fa3cebb375f756f1a87fcf0586c3c Mon Sep 17 00:00:00 2001
From: Corentin Jabot
Date: Mon, 15 Jan 2024 18:09:48 +0100
Subject: [PATCH 1/3] [Clang] Implement CWG2598: Union of non-literal types
A
https://github.com/shafik commented:
Mostly looks good but I would like a second set of eyes.
https://github.com/llvm/llvm-project/pull/78195
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
@@ -208,3 +208,54 @@ namespace dr2565 { // dr2565: 16 open
#endif
}
+
+
+namespace dr2598 { // dr2598: 18
+#if __cplusplus >= 201103L
+struct NonLiteral {
+NonLiteral();
+};
+
+struct anonymous1 {
+union {} a;
+};
+static_assert(__is_literal(anonymous1), "");
+
@@ -208,3 +208,54 @@ namespace dr2565 { // dr2565: 16 open
#endif
}
+
+
+namespace dr2598 { // dr2598: 18
+#if __cplusplus >= 201103L
+struct NonLiteral {
+NonLiteral();
+};
+
+struct anonymous1 {
+union {} a;
+};
+static_assert(__is_literal(anonymous1), "");
+
@@ -208,3 +208,54 @@ namespace dr2565 { // dr2565: 16 open
#endif
}
+
+
+namespace dr2598 { // dr2598: 18
+#if __cplusplus >= 201103L
+struct NonLiteral {
+NonLiteral();
+};
+
+struct anonymous1 {
+union {} a;
+};
+static_assert(__is_literal(anonymous1), "");
+
@@ -1383,6 +1383,34 @@ void CXXRecordDecl::addedMember(Decl *D) {
}
}
+bool CXXRecordDecl::isLiteral() const {
+ const LangOptions = getLangOpts();
+ if (!(LangOpts.CPlusPlus20 ? hasConstexprDestructor()
+ : hasTrivialDestructor()))
+
https://github.com/shafik edited https://github.com/llvm/llvm-project/pull/78195
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/shafik commented:
Is this a potentially breaking change since we have expanded what types are
considered literals and already existing code may observe this fix?
https://github.com/llvm/llvm-project/pull/78195
___
cfe-commits
https://github.com/cor3ntin updated
https://github.com/llvm/llvm-project/pull/78195
>From f354ca458c1fa3cebb375f756f1a87fcf0586c3c Mon Sep 17 00:00:00 2001
From: Corentin Jabot
Date: Mon, 15 Jan 2024 18:09:48 +0100
Subject: [PATCH 1/2] [Clang] Implement CWG2598: Union of non-literal types
A
@@ -1383,6 +1383,34 @@ void CXXRecordDecl::addedMember(Decl *D) {
}
}
+bool CXXRecordDecl::isLiteral() const {
+ const LangOptions = getLangOpts();
+ if (!(LangOpts.CPlusPlus20 ? hasConstexprDestructor()
+ : hasTrivialDestructor()))
+
@@ -1383,6 +1383,34 @@ void CXXRecordDecl::addedMember(Decl *D) {
}
}
+bool CXXRecordDecl::isLiteral() const {
+ const LangOptions = getLangOpts();
+ if (!(LangOpts.CPlusPlus20 ? hasConstexprDestructor()
+ : hasTrivialDestructor()))
+
llvmbot wrote:
@llvm/pr-subscribers-clang
Author: cor3ntin (cor3ntin)
Changes
A union is considered a literal type unless it has no non-literal member.
This resolves CWG2096 (which makes unions with literal members literal) and
CWG2598 (empty unions are literal types).
Fixes #77924
https://github.com/cor3ntin created
https://github.com/llvm/llvm-project/pull/78195
A union is considered a literal type unless it has no non-literal member.
This resolves CWG2096 (which makes unions with literal members literal) and
CWG2598 (empty unions are literal types).
Fixes #77924
34 matches
Mail list logo