[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-10-10 Thread via cfe-commits

https://github.com/kasuga-fj closed 
https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-10-05 Thread via cfe-commits

https://github.com/kasuga-fj updated 
https://github.com/llvm/llvm-project/pull/65246

>From 01ca65833b2248547f1fb4f7d739517e619ac4cd Mon Sep 17 00:00:00 2001
From: "kasuga.ryotaro" 
Date: Wed, 30 Aug 2023 13:26:31 +0900
Subject: [PATCH] [Clang] Fix missing diagnostic for non-standard layout type
 in `offsetof`

Fixes #64619

Clang warns diagnostic for non-standard layout types in `offsetof` only
if they are in evaluated context. With this patch, you'll also get
diagnostic if you use `offsetof` on non-standard layout types in any
other contexts
---
 clang/docs/ReleaseNotes.rst   |  2 +
 clang/lib/Sema/SemaExpr.cpp   |  9 ++-
 clang/test/SemaCXX/class-layout.cpp   | 62 +--
 clang/test/SemaCXX/ms_struct.cpp  |  6 +-
 clang/test/SemaCXX/offsetof.cpp   |  9 +--
 libcxx/include/__type_traits/datasizeof.h |  5 ++
 .../non_trivial_copy_move_ABI.pass.cpp|  2 +-
 .../pairs.pair/trivial_copy_move_ABI.pass.cpp |  1 +
 8 files changed, 52 insertions(+), 44 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ae67a783c2fa2d5..eef9a119bcb41a0 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -270,6 +270,8 @@ Improvements to Clang's diagnostics
 source:1:24: note: expression evaluates to ''\n' (0x0A, 10) == U'' 
(0x1F30D, 127757)'
 1 | static_assert("A\n"[1] == U'');
   |   ~^~~~
+- Clang now always diagnoses when using non-standard layout types in 
``offsetof`` .
+  (`#64619: `_)
 
 Bug Fixes in This Version
 -
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 9c5f96eebd04165..15e2a7978f6b723 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -16796,12 +16796,11 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation 
BuiltinLoc,
 LangOpts.CPlusPlus11? diag::ext_offsetof_non_standardlayout_type
 : diag::ext_offsetof_non_pod_type;
 
-  if (!IsSafe && !DidWarnAboutNonPOD &&
-  DiagRuntimeBehavior(BuiltinLoc, nullptr,
-  PDiag(DiagID)
-  << SourceRange(Components[0].LocStart, OC.LocEnd)
-  << CurrentType))
+  if (!IsSafe && !DidWarnAboutNonPOD && !isUnevaluatedContext()) {
+Diag(BuiltinLoc, DiagID)
+<< SourceRange(Components[0].LocStart, OC.LocEnd) << CurrentType;
 DidWarnAboutNonPOD = true;
+  }
 }
 
 // Look for the field.
diff --git a/clang/test/SemaCXX/class-layout.cpp 
b/clang/test/SemaCXX/class-layout.cpp
index 9782ff08100b2d6..22fb34b8419c583 100644
--- a/clang/test/SemaCXX/class-layout.cpp
+++ b/clang/test/SemaCXX/class-layout.cpp
@@ -1,34 +1,34 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++98 -Wno-inaccessible-base -Wno-c++11-extensions
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base
-// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple x86_64-scei-ps4%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-sie-ps5 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=6 -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=14 -DCLANG_ABI_COMPAT=14
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=16 -DCLANG_ABI_COMPAT=16
-// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 
-Wno-inaccessible-base
-// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 
-Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-
-// RUN: %clang_cc1 

[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-10-05 Thread via cfe-commits

https://github.com/kasuga-fj updated 
https://github.com/llvm/llvm-project/pull/65246

>From 57219322f804a099c66c7ea8f4dd069fdd907e21 Mon Sep 17 00:00:00 2001
From: "kasuga.ryotaro" 
Date: Wed, 30 Aug 2023 13:26:31 +0900
Subject: [PATCH] [Clang] Fix missing diagnostic for non-standard layout type
 in `offsetof`

Fixes #64619

Clang warns diagnostic for non-standard layout types in `offsetof` only
if they are in evaluated context. With this patch, you'll also get
diagnostic if you use `offsetof` on non-standard layout types in any
other contexts
---
 clang/docs/ReleaseNotes.rst   |  2 +
 clang/lib/Sema/SemaExpr.cpp   |  9 ++-
 clang/test/SemaCXX/class-layout.cpp   | 62 +--
 clang/test/SemaCXX/ms_struct.cpp  |  6 +-
 clang/test/SemaCXX/offsetof.cpp   |  9 +--
 libcxx/include/__type_traits/datasizeof.h |  5 ++
 .../non_trivial_copy_move_ABI.pass.cpp|  2 +-
 .../pairs.pair/trivial_copy_move_ABI.pass.cpp |  1 +
 8 files changed, 52 insertions(+), 44 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 2362e479dfbbc5a..f67ceb1d6173c93 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -269,6 +269,8 @@ Improvements to Clang's diagnostics
 source:1:24: note: expression evaluates to ''\n' (0x0A, 10) == U'' 
(0x1F30D, 127757)'
 1 | static_assert("A\n"[1] == U'');
   |   ~^~~~
+- Clang now always diagnoses when using non-standard layout types in 
``offsetof`` .
+  (`#64619: `_)
 
 Bug Fixes in This Version
 -
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 304aa7d105e269b..b86f3c004403afe 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -16796,12 +16796,11 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation 
BuiltinLoc,
 LangOpts.CPlusPlus11? diag::ext_offsetof_non_standardlayout_type
 : diag::ext_offsetof_non_pod_type;
 
-  if (!IsSafe && !DidWarnAboutNonPOD &&
-  DiagRuntimeBehavior(BuiltinLoc, nullptr,
-  PDiag(DiagID)
-  << SourceRange(Components[0].LocStart, OC.LocEnd)
-  << CurrentType))
+  if (!IsSafe && !DidWarnAboutNonPOD && !isUnevaluatedContext()) {
+Diag(BuiltinLoc, DiagID)
+<< SourceRange(Components[0].LocStart, OC.LocEnd) << CurrentType;
 DidWarnAboutNonPOD = true;
+  }
 }
 
 // Look for the field.
diff --git a/clang/test/SemaCXX/class-layout.cpp 
b/clang/test/SemaCXX/class-layout.cpp
index 9782ff08100b2d6..22fb34b8419c583 100644
--- a/clang/test/SemaCXX/class-layout.cpp
+++ b/clang/test/SemaCXX/class-layout.cpp
@@ -1,34 +1,34 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++98 -Wno-inaccessible-base -Wno-c++11-extensions
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base
-// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple x86_64-scei-ps4%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-sie-ps5 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=6 -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=14 -DCLANG_ABI_COMPAT=14
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=16 -DCLANG_ABI_COMPAT=16
-// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 
-Wno-inaccessible-base
-// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 
-Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-
-// RUN: %clang_cc1 

[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-10-05 Thread via cfe-commits

https://github.com/kasuga-fj updated 
https://github.com/llvm/llvm-project/pull/65246

>From aa41086f545daec80770bf17a3cfcc3d3168e394 Mon Sep 17 00:00:00 2001
From: "kasuga.ryotaro" 
Date: Wed, 30 Aug 2023 13:26:31 +0900
Subject: [PATCH] [Clang] Fix missing diagnostic for non-standard layout type
 in `offsetof`

Fixes #64619

Clang warns diagnostic for non-standard layout types in `offsetof` only
if they are in evaluated context. With this patch, you'll also get
diagnostic if you use `offsetof` on non-standard layout types in any
other contexts
---
 clang/docs/ReleaseNotes.rst   |  2 +
 clang/lib/Sema/SemaExpr.cpp   |  9 ++-
 clang/test/SemaCXX/class-layout.cpp   | 62 +--
 clang/test/SemaCXX/ms_struct.cpp  |  6 +-
 clang/test/SemaCXX/offsetof.cpp   |  9 +--
 libcxx/include/__type_traits/datasizeof.h |  5 ++
 .../non_trivial_copy_move_ABI.pass.cpp|  2 +-
 .../pairs.pair/trivial_copy_move_ABI.pass.cpp |  1 +
 8 files changed, 52 insertions(+), 44 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 2362e479dfbbc5a..f67ceb1d6173c93 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -269,6 +269,8 @@ Improvements to Clang's diagnostics
 source:1:24: note: expression evaluates to ''\n' (0x0A, 10) == U'' 
(0x1F30D, 127757)'
 1 | static_assert("A\n"[1] == U'');
   |   ~^~~~
+- Clang now always diagnoses when using non-standard layout types in 
``offsetof`` .
+  (`#64619: `_)
 
 Bug Fixes in This Version
 -
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 304aa7d105e269b..b86f3c004403afe 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -16796,12 +16796,11 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation 
BuiltinLoc,
 LangOpts.CPlusPlus11? diag::ext_offsetof_non_standardlayout_type
 : diag::ext_offsetof_non_pod_type;
 
-  if (!IsSafe && !DidWarnAboutNonPOD &&
-  DiagRuntimeBehavior(BuiltinLoc, nullptr,
-  PDiag(DiagID)
-  << SourceRange(Components[0].LocStart, OC.LocEnd)
-  << CurrentType))
+  if (!IsSafe && !DidWarnAboutNonPOD && !isUnevaluatedContext()) {
+Diag(BuiltinLoc, DiagID)
+<< SourceRange(Components[0].LocStart, OC.LocEnd) << CurrentType;
 DidWarnAboutNonPOD = true;
+  }
 }
 
 // Look for the field.
diff --git a/clang/test/SemaCXX/class-layout.cpp 
b/clang/test/SemaCXX/class-layout.cpp
index 9782ff08100b2d6..22fb34b8419c583 100644
--- a/clang/test/SemaCXX/class-layout.cpp
+++ b/clang/test/SemaCXX/class-layout.cpp
@@ -1,34 +1,34 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++98 -Wno-inaccessible-base -Wno-c++11-extensions
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base
-// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple x86_64-scei-ps4%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-sie-ps5 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=6 -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=14 -DCLANG_ABI_COMPAT=14
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=16 -DCLANG_ABI_COMPAT=16
-// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 
-Wno-inaccessible-base
-// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 
-Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-
-// RUN: %clang_cc1 

[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-10-04 Thread via cfe-commits

https://github.com/kasuga-fj updated 
https://github.com/llvm/llvm-project/pull/65246

>From 1c2f558a80635333655011c723af69371d3587af Mon Sep 17 00:00:00 2001
From: "kasuga.ryotaro" 
Date: Wed, 30 Aug 2023 13:26:31 +0900
Subject: [PATCH 01/13] [Clang] Fix missing diagnostic for non-standard layout
 type in `offsetof`

Fixes #64619

Clang warns diagnostic for non-standard layout types in `offsetof` only
if they are in evaluated context. With this patch, you'll also get
  diagnostic if you use `offsetof` on non-standard layout types in any
  other contexts
---
 clang/lib/Sema/SemaExpr.cpp |  9 -
 clang/test/SemaCXX/class-layout.cpp | 30 ++---
 clang/test/SemaCXX/ms_struct.cpp|  5 ++---
 clang/test/SemaCXX/offsetof.cpp | 10 +-
 4 files changed, 26 insertions(+), 28 deletions(-)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 797b71bffbb451e..c978a2d90f0d877 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -16796,12 +16796,11 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation 
BuiltinLoc,
 LangOpts.CPlusPlus11? diag::ext_offsetof_non_standardlayout_type
 : diag::ext_offsetof_non_pod_type;
 
-  if (!IsSafe && !DidWarnAboutNonPOD &&
-  DiagRuntimeBehavior(BuiltinLoc, nullptr,
-  PDiag(DiagID)
-  << SourceRange(Components[0].LocStart, OC.LocEnd)
-  << CurrentType))
+  if (!IsSafe && !DidWarnAboutNonPOD) {
+Diag(BuiltinLoc, DiagID)
+<< SourceRange(Components[0].LocStart, OC.LocEnd) << CurrentType;
 DidWarnAboutNonPOD = true;
+  }
 }
 
 // Look for the field.
diff --git a/clang/test/SemaCXX/class-layout.cpp 
b/clang/test/SemaCXX/class-layout.cpp
index 9782ff08100b2d6..23b3dbe24249378 100644
--- a/clang/test/SemaCXX/class-layout.cpp
+++ b/clang/test/SemaCXX/class-layout.cpp
@@ -1,18 +1,18 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++98 -Wno-inaccessible-base -Wno-c++11-extensions
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base
-// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple x86_64-scei-ps4%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-sie-ps5 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=6 -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=14 -DCLANG_ABI_COMPAT=14
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=16 -DCLANG_ABI_COMPAT=16
-// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 
-Wno-inaccessible-base
-// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 
-Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++98 -Wno-inaccessible-base -Wno-invalid-offsetof -Wno-c++11-extensions
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof
+// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple x86_64-scei-ps4%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -triple x86_64-sie-ps5 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof 

[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-10-04 Thread via cfe-commits

https://github.com/kasuga-fj updated 
https://github.com/llvm/llvm-project/pull/65246

>From 1c2f558a80635333655011c723af69371d3587af Mon Sep 17 00:00:00 2001
From: "kasuga.ryotaro" 
Date: Wed, 30 Aug 2023 13:26:31 +0900
Subject: [PATCH 01/12] [Clang] Fix missing diagnostic for non-standard layout
 type in `offsetof`

Fixes #64619

Clang warns diagnostic for non-standard layout types in `offsetof` only
if they are in evaluated context. With this patch, you'll also get
  diagnostic if you use `offsetof` on non-standard layout types in any
  other contexts
---
 clang/lib/Sema/SemaExpr.cpp |  9 -
 clang/test/SemaCXX/class-layout.cpp | 30 ++---
 clang/test/SemaCXX/ms_struct.cpp|  5 ++---
 clang/test/SemaCXX/offsetof.cpp | 10 +-
 4 files changed, 26 insertions(+), 28 deletions(-)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 797b71bffbb451e..c978a2d90f0d877 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -16796,12 +16796,11 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation 
BuiltinLoc,
 LangOpts.CPlusPlus11? diag::ext_offsetof_non_standardlayout_type
 : diag::ext_offsetof_non_pod_type;
 
-  if (!IsSafe && !DidWarnAboutNonPOD &&
-  DiagRuntimeBehavior(BuiltinLoc, nullptr,
-  PDiag(DiagID)
-  << SourceRange(Components[0].LocStart, OC.LocEnd)
-  << CurrentType))
+  if (!IsSafe && !DidWarnAboutNonPOD) {
+Diag(BuiltinLoc, DiagID)
+<< SourceRange(Components[0].LocStart, OC.LocEnd) << CurrentType;
 DidWarnAboutNonPOD = true;
+  }
 }
 
 // Look for the field.
diff --git a/clang/test/SemaCXX/class-layout.cpp 
b/clang/test/SemaCXX/class-layout.cpp
index 9782ff08100b2d6..23b3dbe24249378 100644
--- a/clang/test/SemaCXX/class-layout.cpp
+++ b/clang/test/SemaCXX/class-layout.cpp
@@ -1,18 +1,18 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++98 -Wno-inaccessible-base -Wno-c++11-extensions
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base
-// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple x86_64-scei-ps4%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-sie-ps5 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=6 -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=14 -DCLANG_ABI_COMPAT=14
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=16 -DCLANG_ABI_COMPAT=16
-// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 
-Wno-inaccessible-base
-// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 
-Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++98 -Wno-inaccessible-base -Wno-invalid-offsetof -Wno-c++11-extensions
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof
+// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple x86_64-scei-ps4%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -triple x86_64-sie-ps5 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof 

[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-10-02 Thread via cfe-commits

kasuga-fj wrote:

Thanks! (The upstream build process seems to be broken now, so I'll wait until 
it's fixed)

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-10-02 Thread via cfe-commits

https://github.com/philnik777 approved this pull request.

LGTM from the libc++ side of things.

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-10-01 Thread via cfe-commits

https://github.com/kasuga-fj updated 
https://github.com/llvm/llvm-project/pull/65246

>From 7d59f47b9b18ee5db90bb9fd69a1f73f68569ae4 Mon Sep 17 00:00:00 2001
From: "kasuga.ryotaro" 
Date: Wed, 30 Aug 2023 13:26:31 +0900
Subject: [PATCH 01/12] [Clang] Fix missing diagnostic for non-standard layout
 type in `offsetof`

Fixes #64619

Clang warns diagnostic for non-standard layout types in `offsetof` only
if they are in evaluated context. With this patch, you'll also get
  diagnostic if you use `offsetof` on non-standard layout types in any
  other contexts
---
 clang/lib/Sema/SemaExpr.cpp |  9 -
 clang/test/SemaCXX/class-layout.cpp | 30 ++---
 clang/test/SemaCXX/ms_struct.cpp|  5 ++---
 clang/test/SemaCXX/offsetof.cpp | 10 +-
 4 files changed, 26 insertions(+), 28 deletions(-)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 92496b03ecabe54..6537b085aa46c5b 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -16766,12 +16766,11 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation 
BuiltinLoc,
 LangOpts.CPlusPlus11? diag::ext_offsetof_non_standardlayout_type
 : diag::ext_offsetof_non_pod_type;
 
-  if (!IsSafe && !DidWarnAboutNonPOD &&
-  DiagRuntimeBehavior(BuiltinLoc, nullptr,
-  PDiag(DiagID)
-  << SourceRange(Components[0].LocStart, OC.LocEnd)
-  << CurrentType))
+  if (!IsSafe && !DidWarnAboutNonPOD) {
+Diag(BuiltinLoc, DiagID)
+<< SourceRange(Components[0].LocStart, OC.LocEnd) << CurrentType;
 DidWarnAboutNonPOD = true;
+  }
 }
 
 // Look for the field.
diff --git a/clang/test/SemaCXX/class-layout.cpp 
b/clang/test/SemaCXX/class-layout.cpp
index 9782ff08100b2d6..23b3dbe24249378 100644
--- a/clang/test/SemaCXX/class-layout.cpp
+++ b/clang/test/SemaCXX/class-layout.cpp
@@ -1,18 +1,18 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++98 -Wno-inaccessible-base -Wno-c++11-extensions
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base
-// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple x86_64-scei-ps4%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-sie-ps5 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=6 -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=14 -DCLANG_ABI_COMPAT=14
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=16 -DCLANG_ABI_COMPAT=16
-// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 
-Wno-inaccessible-base
-// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 
-Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++98 -Wno-inaccessible-base -Wno-invalid-offsetof -Wno-c++11-extensions
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof
+// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple x86_64-scei-ps4%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -triple x86_64-sie-ps5 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof 

[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-10-01 Thread via cfe-commits

https://github.com/kasuga-fj updated 
https://github.com/llvm/llvm-project/pull/65246

>From 7d59f47b9b18ee5db90bb9fd69a1f73f68569ae4 Mon Sep 17 00:00:00 2001
From: "kasuga.ryotaro" 
Date: Wed, 30 Aug 2023 13:26:31 +0900
Subject: [PATCH 01/11] [Clang] Fix missing diagnostic for non-standard layout
 type in `offsetof`

Fixes #64619

Clang warns diagnostic for non-standard layout types in `offsetof` only
if they are in evaluated context. With this patch, you'll also get
  diagnostic if you use `offsetof` on non-standard layout types in any
  other contexts
---
 clang/lib/Sema/SemaExpr.cpp |  9 -
 clang/test/SemaCXX/class-layout.cpp | 30 ++---
 clang/test/SemaCXX/ms_struct.cpp|  5 ++---
 clang/test/SemaCXX/offsetof.cpp | 10 +-
 4 files changed, 26 insertions(+), 28 deletions(-)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 92496b03ecabe54..6537b085aa46c5b 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -16766,12 +16766,11 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation 
BuiltinLoc,
 LangOpts.CPlusPlus11? diag::ext_offsetof_non_standardlayout_type
 : diag::ext_offsetof_non_pod_type;
 
-  if (!IsSafe && !DidWarnAboutNonPOD &&
-  DiagRuntimeBehavior(BuiltinLoc, nullptr,
-  PDiag(DiagID)
-  << SourceRange(Components[0].LocStart, OC.LocEnd)
-  << CurrentType))
+  if (!IsSafe && !DidWarnAboutNonPOD) {
+Diag(BuiltinLoc, DiagID)
+<< SourceRange(Components[0].LocStart, OC.LocEnd) << CurrentType;
 DidWarnAboutNonPOD = true;
+  }
 }
 
 // Look for the field.
diff --git a/clang/test/SemaCXX/class-layout.cpp 
b/clang/test/SemaCXX/class-layout.cpp
index 9782ff08100b2d6..23b3dbe24249378 100644
--- a/clang/test/SemaCXX/class-layout.cpp
+++ b/clang/test/SemaCXX/class-layout.cpp
@@ -1,18 +1,18 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++98 -Wno-inaccessible-base -Wno-c++11-extensions
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base
-// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple x86_64-scei-ps4%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-sie-ps5 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=6 -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=14 -DCLANG_ABI_COMPAT=14
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=16 -DCLANG_ABI_COMPAT=16
-// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 
-Wno-inaccessible-base
-// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 
-Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++98 -Wno-inaccessible-base -Wno-invalid-offsetof -Wno-c++11-extensions
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof
+// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple x86_64-scei-ps4%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -triple x86_64-sie-ps5 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof 

[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-10-01 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 97829935844e7f35216e12c13231f35fbea640c3 
b9e201a80ee7e79f8ddfe37fee097b8efddc0a8a -- clang/lib/Sema/SemaExpr.cpp 
clang/test/SemaCXX/class-layout.cpp clang/test/SemaCXX/ms_struct.cpp 
clang/test/SemaCXX/offsetof.cpp libcxx/include/__type_traits/datasizeof.h
``





View the diff from clang-format here.


``diff
diff --git a/libcxx/include/__type_traits/datasizeof.h 
b/libcxx/include/__type_traits/datasizeof.h
index cfdd8cbbc..389b006b6 100644
--- a/libcxx/include/__type_traits/datasizeof.h
+++ b/libcxx/include/__type_traits/datasizeof.h
@@ -47,7 +47,8 @@ struct __libcpp_datasizeof {
   };
 #endif
 
-  // _FirstPaddingByte<> is sometimes non-standard layout. Using `offsetof` is 
UB in that case, but GCC and Clang allow the use as an extension.
+  // _FirstPaddingByte<> is sometimes non-standard layout. Using `offsetof` is 
UB in that case, but GCC and Clang allow
+  // the use as an extension.
   // TODO : Find a way to replace `offsetof` ?
   _LIBCPP_DIAGNOSTIC_PUSH
   _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-offsetof")

``




https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-10-01 Thread via cfe-commits

https://github.com/kasuga-fj updated 
https://github.com/llvm/llvm-project/pull/65246

>From 7d59f47b9b18ee5db90bb9fd69a1f73f68569ae4 Mon Sep 17 00:00:00 2001
From: "kasuga.ryotaro" 
Date: Wed, 30 Aug 2023 13:26:31 +0900
Subject: [PATCH 01/10] [Clang] Fix missing diagnostic for non-standard layout
 type in `offsetof`

Fixes #64619

Clang warns diagnostic for non-standard layout types in `offsetof` only
if they are in evaluated context. With this patch, you'll also get
  diagnostic if you use `offsetof` on non-standard layout types in any
  other contexts
---
 clang/lib/Sema/SemaExpr.cpp |  9 -
 clang/test/SemaCXX/class-layout.cpp | 30 ++---
 clang/test/SemaCXX/ms_struct.cpp|  5 ++---
 clang/test/SemaCXX/offsetof.cpp | 10 +-
 4 files changed, 26 insertions(+), 28 deletions(-)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 92496b03ecabe54..6537b085aa46c5b 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -16766,12 +16766,11 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation 
BuiltinLoc,
 LangOpts.CPlusPlus11? diag::ext_offsetof_non_standardlayout_type
 : diag::ext_offsetof_non_pod_type;
 
-  if (!IsSafe && !DidWarnAboutNonPOD &&
-  DiagRuntimeBehavior(BuiltinLoc, nullptr,
-  PDiag(DiagID)
-  << SourceRange(Components[0].LocStart, OC.LocEnd)
-  << CurrentType))
+  if (!IsSafe && !DidWarnAboutNonPOD) {
+Diag(BuiltinLoc, DiagID)
+<< SourceRange(Components[0].LocStart, OC.LocEnd) << CurrentType;
 DidWarnAboutNonPOD = true;
+  }
 }
 
 // Look for the field.
diff --git a/clang/test/SemaCXX/class-layout.cpp 
b/clang/test/SemaCXX/class-layout.cpp
index 9782ff08100b2d6..23b3dbe24249378 100644
--- a/clang/test/SemaCXX/class-layout.cpp
+++ b/clang/test/SemaCXX/class-layout.cpp
@@ -1,18 +1,18 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++98 -Wno-inaccessible-base -Wno-c++11-extensions
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base
-// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple x86_64-scei-ps4%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-sie-ps5 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=6 -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=14 -DCLANG_ABI_COMPAT=14
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=16 -DCLANG_ABI_COMPAT=16
-// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 
-Wno-inaccessible-base
-// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 
-Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++98 -Wno-inaccessible-base -Wno-invalid-offsetof -Wno-c++11-extensions
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof
+// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple x86_64-scei-ps4%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -triple x86_64-sie-ps5 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof 

[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-10-01 Thread via cfe-commits

https://github.com/kasuga-fj updated 
https://github.com/llvm/llvm-project/pull/65246

>From 7d59f47b9b18ee5db90bb9fd69a1f73f68569ae4 Mon Sep 17 00:00:00 2001
From: "kasuga.ryotaro" 
Date: Wed, 30 Aug 2023 13:26:31 +0900
Subject: [PATCH 1/9] [Clang] Fix missing diagnostic for non-standard layout
 type in `offsetof`

Fixes #64619

Clang warns diagnostic for non-standard layout types in `offsetof` only
if they are in evaluated context. With this patch, you'll also get
  diagnostic if you use `offsetof` on non-standard layout types in any
  other contexts
---
 clang/lib/Sema/SemaExpr.cpp |  9 -
 clang/test/SemaCXX/class-layout.cpp | 30 ++---
 clang/test/SemaCXX/ms_struct.cpp|  5 ++---
 clang/test/SemaCXX/offsetof.cpp | 10 +-
 4 files changed, 26 insertions(+), 28 deletions(-)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 92496b03ecabe54..6537b085aa46c5b 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -16766,12 +16766,11 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation 
BuiltinLoc,
 LangOpts.CPlusPlus11? diag::ext_offsetof_non_standardlayout_type
 : diag::ext_offsetof_non_pod_type;
 
-  if (!IsSafe && !DidWarnAboutNonPOD &&
-  DiagRuntimeBehavior(BuiltinLoc, nullptr,
-  PDiag(DiagID)
-  << SourceRange(Components[0].LocStart, OC.LocEnd)
-  << CurrentType))
+  if (!IsSafe && !DidWarnAboutNonPOD) {
+Diag(BuiltinLoc, DiagID)
+<< SourceRange(Components[0].LocStart, OC.LocEnd) << CurrentType;
 DidWarnAboutNonPOD = true;
+  }
 }
 
 // Look for the field.
diff --git a/clang/test/SemaCXX/class-layout.cpp 
b/clang/test/SemaCXX/class-layout.cpp
index 9782ff08100b2d6..23b3dbe24249378 100644
--- a/clang/test/SemaCXX/class-layout.cpp
+++ b/clang/test/SemaCXX/class-layout.cpp
@@ -1,18 +1,18 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++98 -Wno-inaccessible-base -Wno-c++11-extensions
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base
-// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple x86_64-scei-ps4%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-sie-ps5 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=6 -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=14 -DCLANG_ABI_COMPAT=14
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=16 -DCLANG_ABI_COMPAT=16
-// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 
-Wno-inaccessible-base
-// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 
-Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++98 -Wno-inaccessible-base -Wno-invalid-offsetof -Wno-c++11-extensions
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof
+// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple x86_64-scei-ps4%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -triple x86_64-sie-ps5 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof 

[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-10-01 Thread via cfe-commits

https://github.com/kasuga-fj updated 
https://github.com/llvm/llvm-project/pull/65246

>From cc6f7f7cb125f544de708830b3a9c0f39745ed1f Mon Sep 17 00:00:00 2001
From: "kasuga.ryotaro" 
Date: Wed, 30 Aug 2023 13:26:31 +0900
Subject: [PATCH 1/9] [Clang] Fix missing diagnostic for non-standard layout
 type in `offsetof`

Fixes #64619

Clang warns diagnostic for non-standard layout types in `offsetof` only
if they are in evaluated context. With this patch, you'll also get
  diagnostic if you use `offsetof` on non-standard layout types in any
  other contexts
---
 clang/lib/Sema/SemaExpr.cpp |  9 -
 clang/test/SemaCXX/class-layout.cpp | 30 ++---
 clang/test/SemaCXX/ms_struct.cpp|  5 ++---
 clang/test/SemaCXX/offsetof.cpp | 10 +-
 4 files changed, 26 insertions(+), 28 deletions(-)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 92496b03ecabe54..6537b085aa46c5b 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -16766,12 +16766,11 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation 
BuiltinLoc,
 LangOpts.CPlusPlus11? diag::ext_offsetof_non_standardlayout_type
 : diag::ext_offsetof_non_pod_type;
 
-  if (!IsSafe && !DidWarnAboutNonPOD &&
-  DiagRuntimeBehavior(BuiltinLoc, nullptr,
-  PDiag(DiagID)
-  << SourceRange(Components[0].LocStart, OC.LocEnd)
-  << CurrentType))
+  if (!IsSafe && !DidWarnAboutNonPOD) {
+Diag(BuiltinLoc, DiagID)
+<< SourceRange(Components[0].LocStart, OC.LocEnd) << CurrentType;
 DidWarnAboutNonPOD = true;
+  }
 }
 
 // Look for the field.
diff --git a/clang/test/SemaCXX/class-layout.cpp 
b/clang/test/SemaCXX/class-layout.cpp
index 9782ff08100b2d6..23b3dbe24249378 100644
--- a/clang/test/SemaCXX/class-layout.cpp
+++ b/clang/test/SemaCXX/class-layout.cpp
@@ -1,18 +1,18 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++98 -Wno-inaccessible-base -Wno-c++11-extensions
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base
-// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple x86_64-scei-ps4%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-sie-ps5 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=6 -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=14 -DCLANG_ABI_COMPAT=14
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=16 -DCLANG_ABI_COMPAT=16
-// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 
-Wno-inaccessible-base
-// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 
-Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++98 -Wno-inaccessible-base -Wno-invalid-offsetof -Wno-c++11-extensions
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof
+// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple x86_64-scei-ps4%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -triple x86_64-sie-ps5 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof 

[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-29 Thread Louis Dionne via cfe-commits

ldionne wrote:

> Previous CI failures due to `offsetof` warnings have been resolved. Thank you 
> for your cooperation! The current CI error (libcxx-ci Benchmark) does not 
> seem to be caused by this patch (other PRs seem to be failing in the same 
> one), so I'll wait until it's fixed.

The CI issues with the Benchmarks should be fixed now, so if you rebase onto 
`main` it shouldn't be a problem anymore

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-29 Thread via cfe-commits


@@ -47,7 +47,13 @@ struct __libcpp_datasizeof {
   };
 #endif
 
+  // Disable warnings related to the use of `offsetof` on non-standard layout 
or non-POD types
+  // TODO : Find a way to replace `offsetof` ?

philnik777 wrote:

I don't think this TODO is actionable from the libc++ side of things currently, 
so I'd rather not add it. `offsetof` is the right tool for what we are trying 
to achieve - even if it's technically UB.

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-29 Thread via cfe-commits


@@ -47,7 +47,13 @@ struct __libcpp_datasizeof {
   };
 #endif
 
+  // Disable warnings related to the use of `offsetof` on non-standard layout 
or non-POD types

philnik777 wrote:

```suggestion
  // _FirstPaddingByte<> is sometimes non-standard layout. Using `offsetof` is 
UB in that case, but GCC and Clang allow the use as an extension.
```

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-29 Thread via cfe-commits


@@ -47,7 +47,13 @@ struct __libcpp_datasizeof {
   };
 #endif
 
+  // Disable warnings related to the use of `offsetof` on non-standard layout 
or non-POD types
+  // TODO : Find a way to replace `offsetof` ?
+  _LIBCPP_DIAGNOSTIC_PUSH
+  _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-offsetof")
+  _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Winvalid-offsetof")

philnik777 wrote:

GCC doesn't warn on this, so we shouldn't suppress anything here.

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-29 Thread via cfe-commits

kasuga-fj wrote:

Previous CI failures due to `offsetof` warnings have been resolved. Thank you 
for your cooperation! The current CI error (libcxx-ci Benchmark) does not seem 
to be caused by this patch (other PRs seem to be failing in the same one), so 
I'll wait until it's fixed.

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-28 Thread via cfe-commits


@@ -47,7 +47,11 @@ struct __libcpp_datasizeof {
   };
 #endif
 

kasuga-fj wrote:

Done. Thanks

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-28 Thread via cfe-commits

https://github.com/kasuga-fj updated 
https://github.com/llvm/llvm-project/pull/65246

>From cc6f7f7cb125f544de708830b3a9c0f39745ed1f Mon Sep 17 00:00:00 2001
From: "kasuga.ryotaro" 
Date: Wed, 30 Aug 2023 13:26:31 +0900
Subject: [PATCH 1/8] [Clang] Fix missing diagnostic for non-standard layout
 type in `offsetof`

Fixes #64619

Clang warns diagnostic for non-standard layout types in `offsetof` only
if they are in evaluated context. With this patch, you'll also get
  diagnostic if you use `offsetof` on non-standard layout types in any
  other contexts
---
 clang/lib/Sema/SemaExpr.cpp |  9 -
 clang/test/SemaCXX/class-layout.cpp | 30 ++---
 clang/test/SemaCXX/ms_struct.cpp|  5 ++---
 clang/test/SemaCXX/offsetof.cpp | 10 +-
 4 files changed, 26 insertions(+), 28 deletions(-)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 92496b03ecabe54..6537b085aa46c5b 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -16766,12 +16766,11 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation 
BuiltinLoc,
 LangOpts.CPlusPlus11? diag::ext_offsetof_non_standardlayout_type
 : diag::ext_offsetof_non_pod_type;
 
-  if (!IsSafe && !DidWarnAboutNonPOD &&
-  DiagRuntimeBehavior(BuiltinLoc, nullptr,
-  PDiag(DiagID)
-  << SourceRange(Components[0].LocStart, OC.LocEnd)
-  << CurrentType))
+  if (!IsSafe && !DidWarnAboutNonPOD) {
+Diag(BuiltinLoc, DiagID)
+<< SourceRange(Components[0].LocStart, OC.LocEnd) << CurrentType;
 DidWarnAboutNonPOD = true;
+  }
 }
 
 // Look for the field.
diff --git a/clang/test/SemaCXX/class-layout.cpp 
b/clang/test/SemaCXX/class-layout.cpp
index 9782ff08100b2d6..23b3dbe24249378 100644
--- a/clang/test/SemaCXX/class-layout.cpp
+++ b/clang/test/SemaCXX/class-layout.cpp
@@ -1,18 +1,18 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++98 -Wno-inaccessible-base -Wno-c++11-extensions
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base
-// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple x86_64-scei-ps4%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-sie-ps5 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=6 -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=14 -DCLANG_ABI_COMPAT=14
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=16 -DCLANG_ABI_COMPAT=16
-// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 
-Wno-inaccessible-base
-// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 
-Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++98 -Wno-inaccessible-base -Wno-invalid-offsetof -Wno-c++11-extensions
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof
+// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple x86_64-scei-ps4%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -triple x86_64-sie-ps5 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof 

[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-28 Thread via cfe-commits


@@ -47,7 +47,11 @@ struct __libcpp_datasizeof {
   };
 #endif
 

phyBrackets wrote:

Optional : Can you add a brief comment/note that why warnings are suppressed 
here? 
Mb something like : 

``` 
// Disable warnings related to the use of `offsetof` on non-standard layout 
types 
// TODO : Find a way to replace offsetof ?
```

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-28 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-libcxx


Changes

Fixes #64619

Clang warns diagnostic for non-standard layout types in `offsetof` only if they 
are in evaluated context. With this patch, you'll also get diagnostic if you 
use `offsetof` on non-standard layout types in any other contexts

---
Full diff: https://github.com/llvm/llvm-project/pull/65246.diff


6 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+2) 
- (modified) clang/lib/Sema/SemaExpr.cpp (+4-5) 
- (modified) clang/test/SemaCXX/class-layout.cpp (+15-15) 
- (modified) clang/test/SemaCXX/ms_struct.cpp (+3-3) 
- (modified) clang/test/SemaCXX/offsetof.cpp (+5-4) 
- (modified) libcxx/include/__type_traits/datasizeof.h (+4) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index f314c9c72fa28b7..abc36bac05d788d 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -208,6 +208,8 @@ Improvements to Clang's diagnostics
   (`#54678: `_).
 - Clang now prints its 'note' diagnostic in cyan instead of black, to be more 
compatible
   with terminals with dark background colors. This is also more consistent 
with GCC.
+- Clang now always diagnoses when using non-standard layout types in 
``offsetof`` .
+  (`#64619: `_)
 
 Bug Fixes in This Version
 -
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 92496b03ecabe54..fedea932c5e15fe 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -16766,12 +16766,11 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation 
BuiltinLoc,
 LangOpts.CPlusPlus11? diag::ext_offsetof_non_standardlayout_type
 : diag::ext_offsetof_non_pod_type;
 
-  if (!IsSafe && !DidWarnAboutNonPOD &&
-  DiagRuntimeBehavior(BuiltinLoc, nullptr,
-  PDiag(DiagID)
-  << SourceRange(Components[0].LocStart, OC.LocEnd)
-  << CurrentType))
+  if (!IsSafe && !DidWarnAboutNonPOD && !isUnevaluatedContext()) {
+Diag(BuiltinLoc, DiagID)
+<< SourceRange(Components[0].LocStart, OC.LocEnd) << CurrentType;
 DidWarnAboutNonPOD = true;
+  }
 }
 
 // Look for the field.
diff --git a/clang/test/SemaCXX/class-layout.cpp 
b/clang/test/SemaCXX/class-layout.cpp
index 9782ff08100b2d6..23b3dbe24249378 100644
--- a/clang/test/SemaCXX/class-layout.cpp
+++ b/clang/test/SemaCXX/class-layout.cpp
@@ -1,18 +1,18 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++98 -Wno-inaccessible-base -Wno-c++11-extensions
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base
-// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple x86_64-scei-ps4%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-sie-ps5 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=6 -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=14 -DCLANG_ABI_COMPAT=14
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=16 -DCLANG_ABI_COMPAT=16
-// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 
-Wno-inaccessible-base
-// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 
-Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++98 -Wno-inaccessible-base -Wno-invalid-offsetof -Wno-c++11-extensions
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof
+// 

[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-28 Thread via cfe-commits

https://github.com/kasuga-fj updated 
https://github.com/llvm/llvm-project/pull/65246

>From cc6f7f7cb125f544de708830b3a9c0f39745ed1f Mon Sep 17 00:00:00 2001
From: "kasuga.ryotaro" 
Date: Wed, 30 Aug 2023 13:26:31 +0900
Subject: [PATCH 1/7] [Clang] Fix missing diagnostic for non-standard layout
 type in `offsetof`

Fixes #64619

Clang warns diagnostic for non-standard layout types in `offsetof` only
if they are in evaluated context. With this patch, you'll also get
  diagnostic if you use `offsetof` on non-standard layout types in any
  other contexts
---
 clang/lib/Sema/SemaExpr.cpp |  9 -
 clang/test/SemaCXX/class-layout.cpp | 30 ++---
 clang/test/SemaCXX/ms_struct.cpp|  5 ++---
 clang/test/SemaCXX/offsetof.cpp | 10 +-
 4 files changed, 26 insertions(+), 28 deletions(-)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 92496b03ecabe54..6537b085aa46c5b 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -16766,12 +16766,11 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation 
BuiltinLoc,
 LangOpts.CPlusPlus11? diag::ext_offsetof_non_standardlayout_type
 : diag::ext_offsetof_non_pod_type;
 
-  if (!IsSafe && !DidWarnAboutNonPOD &&
-  DiagRuntimeBehavior(BuiltinLoc, nullptr,
-  PDiag(DiagID)
-  << SourceRange(Components[0].LocStart, OC.LocEnd)
-  << CurrentType))
+  if (!IsSafe && !DidWarnAboutNonPOD) {
+Diag(BuiltinLoc, DiagID)
+<< SourceRange(Components[0].LocStart, OC.LocEnd) << CurrentType;
 DidWarnAboutNonPOD = true;
+  }
 }
 
 // Look for the field.
diff --git a/clang/test/SemaCXX/class-layout.cpp 
b/clang/test/SemaCXX/class-layout.cpp
index 9782ff08100b2d6..23b3dbe24249378 100644
--- a/clang/test/SemaCXX/class-layout.cpp
+++ b/clang/test/SemaCXX/class-layout.cpp
@@ -1,18 +1,18 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++98 -Wno-inaccessible-base -Wno-c++11-extensions
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base
-// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple x86_64-scei-ps4%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-sie-ps5 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=6 -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=14 -DCLANG_ABI_COMPAT=14
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=16 -DCLANG_ABI_COMPAT=16
-// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 
-Wno-inaccessible-base
-// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 
-Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++98 -Wno-inaccessible-base -Wno-invalid-offsetof -Wno-c++11-extensions
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof
+// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple x86_64-scei-ps4%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -triple x86_64-sie-ps5 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof 

[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-27 Thread Louis Dionne via cfe-commits

ldionne wrote:

@kasuga-fj Ok, let's take the diff I posted earlier in the comments and silence 
the warning in libc++ then. Once you do that, the libc++ test suite shouldn't 
fail with your patch anymore so your CI should be green. Then libc++ will be 
out of your way and it's up to the Clang folks whether this is worth doing.

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-26 Thread via cfe-commits

philnik777 wrote:

Assuming that Clang doesn't plan on optimizing anything based on this, I think 
it should be fine to just silence the warning. We could also add a 
`__datasizeof` builtin in a separate patch if we want. That would probably be 
less error-prone and cheaper than our current solution. FWIW we'll need some 
version of this when we want to replace `__compressed_pair`, so a cheaper 
solution would probably be a good idea.

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-26 Thread via cfe-commits

kasuga-fj wrote:

> Do we have any Github workflow documentation that mentions we shouldn't 
> force-push to update PRs?

According to the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html#rebasing-pull-requests-and-force-pushes),
 we should generally avoid rebasing and pushing force. But I trust it will be 
allowed in this case.

> My question is about the desired end state of libc++, not whether that end 
> state should be achieved in this specific patch or not.

I misunderstood, sorry. I'm not an expert of libcxx, so I cannot determine what 
is should be (although it is only what an amateur thinks, at least it seems to 
be working fine now, so just suppressing warning would not be a big problem, I 
think). 
Incidentally, as you may have already noticed, it may be worth noting that a 
relatively recent commit introduced `__libcpp_datasizeof` 
(https://github.com/llvm/llvm-project/commit/c4e98722ca79c827dd57b809e0ef16b3b8da8c72).

> Certainly _FirstPaddingByte<> can't be standard layout if the T it holds is 
> not standard layout?

Yes, you are correct. I was only checking with standard-layout class... I tried 
passing a non-standard layout class in the type parameter and 
`_FirstPaddingByte<>` became non standard-layout. By the way, I checked the 
CI's failure log and it looks that perhaps there is no test which uses 
`__libcpp_datasizeof` with non standard-layout type (I may have missed 
something). I think it would be better adding such one.

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-25 Thread Louis Dionne via cfe-commits

ldionne wrote:

> Thank you for your review! Here are some comments and my thoughts.
> 
> > Note that you should probably rebase your patch onto main and force-push to 
> > update the PR
> 
> Does it mean that I can rebase and force-push since (it should be avoided in 
> normal case but) this is a special case?

That's what I usually do. Do we have any Github workflow documentation that 
mentions we shouldn't force-push to update PRs? If so, I am not aware of it.

> 
> > So... should we strive to eradicate this from libc++ in the first place, or 
> > should we just silence the warning. WDYT?
> 
> I think it's good to only silence the warning and (if necessary) leave some 
> TODO comments about the `offsetof` usage because it's undesirable for this 
> patch to be larger than it needs to be..

My question is about the desired end state of libc++, not whether that end 
state should be achieved in this specific patch or not.

> 
> > Also, given that it is conditionally supported in C++17, I assume this 
> > warning doesn't trigger at all in C++17 mode, right?
> 
> I believe the purpose of this warning is to tell you that your program works 
> now, but may not be compiled with another compiler. So the similar warning 
> should appear even in C++17 mode. I chedked and found that 
> `_FirstPaddingByte<>` is ~standard layout but non-POD~ both standard-layout 
> and POD (I checked them with `std::is_standard_layout` and `std::is_pod`). 
> Using `offsetof` with a standard-layout class is supported in C++17, so I 
> guess there is no warning

What `T` type did you use to check that `_FirstPaddingByte<>` was standard 
layout and POD? Certainly `_FirstPaddingByte<>` can't be standard layout if the 
`T` it holds is not standard layout?

@philnik777 do you have thoughts on this?

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-22 Thread via cfe-commits

kasuga-fj wrote:

Thank you for your review! Here are some comments and my thoughts.

> Note that you should probably rebase your patch onto main and force-push to 
> update the PR

Does it mean that I can rebase and force-push since (it should be avoided in 
normal case but) this is a special case?

> So... should we strive to eradicate this from libc++ in the first place, or 
> should we just silence the warning. WDYT?

I think it's good to only silence the warning and (if necessary) leave some 
TODO comments about the `offsetof` usage because it's undesirable for this 
patch to be larger than it needs to be..

> Also, given that it is conditionally supported in C++17, I assume this 
> warning doesn't trigger at all in C++17 mode, right?

I believe the purpose of this warning is to tell you that your program works 
now, but may not be compiled with another compiler. So the similar warning 
should appear even in C++17 mode. I chedked and found that 
`_FirstPaddingByte<>` is standard layout but non-POD (I checked them with 
`std::is_standard_layout` and `std::is_pod`). Using `offsetof` with a 
standard-layout class is supported in C++17, so I guess there is no warning 

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-21 Thread Louis Dionne via cfe-commits

ldionne wrote:

Ok so after scratching my head a bit, I'm actually not certain of how to 
proceed with this. I can't find a way to implement `__libcpp_datasizeof` in 
libc++ that doesn't involve `offsetof`, so our only option would be to silence 
the warning. We could do it like (if we end up doing that, just take that diff 
and incorporate it to your patch, we can land both at once and the libc++ CI 
will also trigger):

```
diff --git a/libcxx/include/__type_traits/datasizeof.h 
b/libcxx/include/__type_traits/datasizeof.h
index 019099a9cf18..88a702470c3c 100644
--- a/libcxx/include/__type_traits/datasizeof.h
+++ b/libcxx/include/__type_traits/datasizeof.h
@@ -47,7 +47,11 @@ struct __libcpp_datasizeof {
   };
 #endif
 
+  _LIBCPP_DIAGNOSTIC_PUSH
+  _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-offsetof")
+  _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Winvalid-offsetof")
   static const size_t value = offsetof(_FirstPaddingByte<>, 
__first_padding_byte_);
+  _LIBCPP_DIAGNOSTIC_POP
 };
 
 _LIBCPP_END_NAMESPACE_STD
```

However, in C++03, using `offsetof` with a non-POD is undefined behavior (hence 
the warning, I guess). So we'd technically have UB in our code here, which 
isn't great. In C++17 doing that is conditionally supported, so I guess we're 
fine.

So... should we strive to eradicate this from libc++ in the first place, or 
should we just silence the warning. WDYT?

Also, given that it is conditionally supported in C++17, I assume this warning 
doesn't trigger at all in C++17 mode, right?

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-21 Thread Louis Dionne via cfe-commits

ldionne wrote:

Note that you should probably rebase your patch onto `main` and force-push to 
update the PR. The CI for Clang now runs on Windows from GH PRs as well (it 
used not to when you submitted the patch, I think).

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-21 Thread Louis Dionne via cfe-commits

ldionne wrote:

I think when the @llvm/pr-subscribers-libcxx group was pinged 2 weeks ago, most 
of us didn't have the right GH notifications set up yet and we didn't see it. 
Looking now.

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-21 Thread via cfe-commits

cor3ntin wrote:

@philnik777 may be able to help

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-19 Thread via cfe-commits

kasuga-fj wrote:

@llvm/pr-subscribers-libcxx  Could you please check this comment? 
https://github.com/llvm/llvm-project/pull/65246#issuecomment-1706219059

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-06 Thread via cfe-commits

https://github.com/cor3ntin approved this pull request.


https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-05 Thread via cfe-commits


@@ -17,7 +17,7 @@ struct Base { int x; };
 struct Derived : Base { int y; };
 int o = __builtin_offsetof(Derived, x); // expected-warning{{offset of on 
non-POD type}}
 
-const int o2 = sizeof(__builtin_offsetof(Derived, x));
+const int o2 = sizeof(__builtin_offsetof(Derived, x)); // 
expected-warning{{offset of on non-POD type 'Derived'}}

kasuga-fj wrote:

Fixed. Thanks.

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-05 Thread via cfe-commits

https://github.com/kasuga-fj updated 
https://github.com/llvm/llvm-project/pull/65246:

>From d15196f5148194c5cb2f59c438d06f9fa61c8b4a Mon Sep 17 00:00:00 2001
From: "kasuga.ryotaro" 
Date: Wed, 30 Aug 2023 13:26:31 +0900
Subject: [PATCH 1/6] [Clang] Fix missing diagnostic for non-standard layout
 type in `offsetof`

Fixes #64619

Clang warns diagnostic for non-standard layout types in `offsetof` only
if they are in evaluated context. With this patch, you'll also get
  diagnostic if you use `offsetof` on non-standard layout types in any
  other contexts
---
 clang/lib/Sema/SemaExpr.cpp |  9 -
 clang/test/SemaCXX/class-layout.cpp | 30 ++---
 clang/test/SemaCXX/ms_struct.cpp|  5 ++---
 clang/test/SemaCXX/offsetof.cpp | 10 +-
 4 files changed, 26 insertions(+), 28 deletions(-)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index f9badf4ede847f..d78d823e15e62d 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -16750,12 +16750,11 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation 
BuiltinLoc,
 LangOpts.CPlusPlus11? diag::ext_offsetof_non_standardlayout_type
 : diag::ext_offsetof_non_pod_type;
 
-  if (!IsSafe && !DidWarnAboutNonPOD &&
-  DiagRuntimeBehavior(BuiltinLoc, nullptr,
-  PDiag(DiagID)
-  << SourceRange(Components[0].LocStart, OC.LocEnd)
-  << CurrentType))
+  if (!IsSafe && !DidWarnAboutNonPOD) {
+Diag(BuiltinLoc, DiagID)
+<< SourceRange(Components[0].LocStart, OC.LocEnd) << CurrentType;
 DidWarnAboutNonPOD = true;
+  }
 }
 
 // Look for the field.
diff --git a/clang/test/SemaCXX/class-layout.cpp 
b/clang/test/SemaCXX/class-layout.cpp
index 3ccd0ad25d7e75..a5660e10fe725a 100644
--- a/clang/test/SemaCXX/class-layout.cpp
+++ b/clang/test/SemaCXX/class-layout.cpp
@@ -1,18 +1,18 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++98 -Wno-inaccessible-base -Wno-c++11-extensions
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base
-// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple x86_64-scei-ps4%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-sie-ps5 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=6 -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=14 -DCLANG_ABI_COMPAT=14
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=16 -DCLANG_ABI_COMPAT=16
-// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 
-Wno-inaccessible-base
-// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 
-Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++98 -Wno-inaccessible-base -Wno-invalid-offsetof -Wno-c++11-extensions
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof
+// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple x86_64-scei-ps4%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -triple x86_64-sie-ps5 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -fclang-abi-compat=6 

[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-05 Thread Aaron Ballman via cfe-commits


@@ -17,7 +17,7 @@ struct Base { int x; };
 struct Derived : Base { int y; };
 int o = __builtin_offsetof(Derived, x); // expected-warning{{offset of on 
non-POD type}}
 
-const int o2 = sizeof(__builtin_offsetof(Derived, x));
+const int o2 = sizeof(__builtin_offsetof(Derived, x)); // 
expected-warning{{offset of on non-POD type 'Derived'}}

AaronBallman wrote:

I think that might produce slightly better results by silencing this kind of 
warning.

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-05 Thread via cfe-commits


@@ -17,7 +17,7 @@ struct Base { int x; };
 struct Derived : Base { int y; };
 int o = __builtin_offsetof(Derived, x); // expected-warning{{offset of on 
non-POD type}}
 
-const int o2 = sizeof(__builtin_offsetof(Derived, x));
+const int o2 = sizeof(__builtin_offsetof(Derived, x)); // 
expected-warning{{offset of on non-POD type 'Derived'}}

cor3ntin wrote:

So you think we should ie, check for `!isUnevaluated()` - ie diag in constant 
expressions but not in unevaluated contexts?

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-05 Thread Aaron Ballman via cfe-commits


@@ -25,6 +25,7 @@ struct B : public A {
 
 static_assert(__builtin_offsetof(B, d) == 12,
   "We can't allocate the bitfield into the padding under ms_struct");
+// expected-warning@-2 {{offset of on non-standard-layout type 'B'}}

AaronBallman wrote:

I think this diagnostic is an improvement over the status quo.

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-05 Thread Aaron Ballman via cfe-commits


@@ -17,7 +17,7 @@ struct Base { int x; };
 struct Derived : Base { int y; };
 int o = __builtin_offsetof(Derived, x); // expected-warning{{offset of on 
non-POD type}}
 
-const int o2 = sizeof(__builtin_offsetof(Derived, x));
+const int o2 = sizeof(__builtin_offsetof(Derived, x)); // 
expected-warning{{offset of on non-POD type 'Derived'}}

AaronBallman wrote:

This is an example of why I think the existing behavior is correct. The fact 
that we're asking for the offset of a field on a non-POD type is not harmful 
because the call is never evaluated.

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-05 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman approved this pull request.

Hmmm, in some ways I think this is making the diagnostic needlessly chatty, and 
in other ways the new diagnostic behavior seems reasonable.

On balance, I think the improvements outweigh the regressions, especially for 
code users are likely to hit. e.g., I suspect there's way more use of offsetof 
in a static assertion than there are uses of offsetof as an operand to sizeof.

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-05 Thread Aaron Ballman via cfe-commits


@@ -50,9 +50,9 @@ struct Derived2 : public Base1, public Base2 {
   int z; 
 };
 
-int derived1[__builtin_offsetof(Derived2, x) == 0? 1 : -1];
-int derived2[__builtin_offsetof(Derived2, y)  == 4? 1 : -1];
-int derived3[__builtin_offsetof(Derived2, z)  == 8? 1 : -1];
+int derived1[__builtin_offsetof(Derived2, x) == 0? 1 : -1]; // 
expected-warning{{offset of on non-POD type 'Derived2'}}

AaronBallman wrote:

This also seems like an improvement in diagnostic behavior.

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-05 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman edited 
https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-05 Thread Tobias Hieta via cfe-commits

tru wrote:

Ping @llvm/pr-subscribers-libcxx 

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-05 Thread via cfe-commits

kasuga-fj wrote:

The CI failed because `libcxx` uses `offsetof`.
https://github.com/kasuga-fj/llvm-project/blob/b9c767a6a128f57858273eb43d4383e83d0d086b/libcxx/include/__type_traits/datasizeof.h#L50
I investigated but couldn't figure out where to fix it (Should I change the 
compile time options?). Could someone please help me? It may be unrelated, but 
I am also concerned that "libc++ test suite in C++03" failed while "libc++ test 
suite in C++26" succeeded.

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-04 Thread Mikhail Goncharov via cfe-commits

metaflow wrote:

alright, build has been triggered successfully! thank you <3

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-04 Thread via cfe-commits

https://github.com/kasuga-fj updated 
https://github.com/llvm/llvm-project/pull/65246:

>From d15196f5148194c5cb2f59c438d06f9fa61c8b4a Mon Sep 17 00:00:00 2001
From: "kasuga.ryotaro" 
Date: Wed, 30 Aug 2023 13:26:31 +0900
Subject: [PATCH 1/5] [Clang] Fix missing diagnostic for non-standard layout
 type in `offsetof`

Fixes #64619

Clang warns diagnostic for non-standard layout types in `offsetof` only
if they are in evaluated context. With this patch, you'll also get
  diagnostic if you use `offsetof` on non-standard layout types in any
  other contexts
---
 clang/lib/Sema/SemaExpr.cpp |  9 -
 clang/test/SemaCXX/class-layout.cpp | 30 ++---
 clang/test/SemaCXX/ms_struct.cpp|  5 ++---
 clang/test/SemaCXX/offsetof.cpp | 10 +-
 4 files changed, 26 insertions(+), 28 deletions(-)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index f9badf4ede847f..d78d823e15e62d 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -16750,12 +16750,11 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation 
BuiltinLoc,
 LangOpts.CPlusPlus11? diag::ext_offsetof_non_standardlayout_type
 : diag::ext_offsetof_non_pod_type;
 
-  if (!IsSafe && !DidWarnAboutNonPOD &&
-  DiagRuntimeBehavior(BuiltinLoc, nullptr,
-  PDiag(DiagID)
-  << SourceRange(Components[0].LocStart, OC.LocEnd)
-  << CurrentType))
+  if (!IsSafe && !DidWarnAboutNonPOD) {
+Diag(BuiltinLoc, DiagID)
+<< SourceRange(Components[0].LocStart, OC.LocEnd) << CurrentType;
 DidWarnAboutNonPOD = true;
+  }
 }
 
 // Look for the field.
diff --git a/clang/test/SemaCXX/class-layout.cpp 
b/clang/test/SemaCXX/class-layout.cpp
index 3ccd0ad25d7e75..a5660e10fe725a 100644
--- a/clang/test/SemaCXX/class-layout.cpp
+++ b/clang/test/SemaCXX/class-layout.cpp
@@ -1,18 +1,18 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++98 -Wno-inaccessible-base -Wno-c++11-extensions
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base
-// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple x86_64-scei-ps4%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-sie-ps5 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=6 -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=14 -DCLANG_ABI_COMPAT=14
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=16 -DCLANG_ABI_COMPAT=16
-// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 
-Wno-inaccessible-base
-// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 
-Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++98 -Wno-inaccessible-base -Wno-invalid-offsetof -Wno-c++11-extensions
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof
+// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple x86_64-scei-ps4%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -triple x86_64-sie-ps5 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -fclang-abi-compat=6 

[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-04 Thread Takuya Shimizu via cfe-commits

hazohelet wrote:

Adding an irrelevant new line in a modified test file would suffice to trigger 
the CI build.
Force-pushing doesn't seem to be desirable during code review.

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-04 Thread via cfe-commits

kasuga-fj wrote:

Ah, thanks. Then what should I do? Can I make another commit with the same 
content as the last commit and force push? (sorry, I don't fully understand the 
LLVM's PR rules)

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-04 Thread Takuya Shimizu via cfe-commits

hazohelet wrote:

FWIW, an empty commit didn't trigger CI correctly yesterday, so pushing a 
non-empty commit might fix the CI issue.

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-04 Thread via cfe-commits

kasuga-fj wrote:

@metaflow I added an empty commit and the build was triggered, but it still 
failed. Could you help me?

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-04 Thread via cfe-commits

https://github.com/kasuga-fj updated 
https://github.com/llvm/llvm-project/pull/65246:

>From d15196f5148194c5cb2f59c438d06f9fa61c8b4a Mon Sep 17 00:00:00 2001
From: "kasuga.ryotaro" 
Date: Wed, 30 Aug 2023 13:26:31 +0900
Subject: [PATCH 1/4] [Clang] Fix missing diagnostic for non-standard layout
 type in `offsetof`

Fixes #64619

Clang warns diagnostic for non-standard layout types in `offsetof` only
if they are in evaluated context. With this patch, you'll also get
  diagnostic if you use `offsetof` on non-standard layout types in any
  other contexts
---
 clang/lib/Sema/SemaExpr.cpp |  9 -
 clang/test/SemaCXX/class-layout.cpp | 30 ++---
 clang/test/SemaCXX/ms_struct.cpp|  5 ++---
 clang/test/SemaCXX/offsetof.cpp | 10 +-
 4 files changed, 26 insertions(+), 28 deletions(-)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index f9badf4ede847f9..d78d823e15e62d7 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -16750,12 +16750,11 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation 
BuiltinLoc,
 LangOpts.CPlusPlus11? diag::ext_offsetof_non_standardlayout_type
 : diag::ext_offsetof_non_pod_type;
 
-  if (!IsSafe && !DidWarnAboutNonPOD &&
-  DiagRuntimeBehavior(BuiltinLoc, nullptr,
-  PDiag(DiagID)
-  << SourceRange(Components[0].LocStart, OC.LocEnd)
-  << CurrentType))
+  if (!IsSafe && !DidWarnAboutNonPOD) {
+Diag(BuiltinLoc, DiagID)
+<< SourceRange(Components[0].LocStart, OC.LocEnd) << CurrentType;
 DidWarnAboutNonPOD = true;
+  }
 }
 
 // Look for the field.
diff --git a/clang/test/SemaCXX/class-layout.cpp 
b/clang/test/SemaCXX/class-layout.cpp
index 3ccd0ad25d7e753..a5660e10fe725a5 100644
--- a/clang/test/SemaCXX/class-layout.cpp
+++ b/clang/test/SemaCXX/class-layout.cpp
@@ -1,18 +1,18 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++98 -Wno-inaccessible-base -Wno-c++11-extensions
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base
-// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple x86_64-scei-ps4%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-sie-ps5 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=6 -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=14 -DCLANG_ABI_COMPAT=14
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=16 -DCLANG_ABI_COMPAT=16
-// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 
-Wno-inaccessible-base
-// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 
-Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++98 -Wno-inaccessible-base -Wno-invalid-offsetof -Wno-c++11-extensions
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof
+// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple x86_64-scei-ps4%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -triple x86_64-sie-ps5 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof 

[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-04 Thread Timm Baeder via cfe-commits

tbaederr wrote:

@cor3ntin Yes, I wrote this in the wrong PR :facepalm: 

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-04 Thread Mikhail Goncharov via cfe-commits

metaflow wrote:

@kasuga-fj could you please re-upload change to trigger the build?

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-04 Thread via cfe-commits

cor3ntin wrote:

@tbaederr We are getting rather conservative as to what gets backported. I 
think that does not meet the bar.
Maybe for 17.0.x

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-04 Thread Timm Baeder via cfe-commits

tbaederr wrote:

Okay, makes sense to me. Should probably also be backported to 17.

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-04 Thread via cfe-commits


@@ -39,6 +40,4 @@ struct C {
 
 static_assert(__builtin_offsetof(C, n) == 8,
   "long long field in ms_struct should be 8-byte aligned");
-#if !defined(TEST_FOR_ERROR) && !defined(TEST_FOR_WARNING)
-// expected-no-diagnostics
-#endif
+// expected-warning@-2 {{offset of on non-standard-layout type 'C'}}

cor3ntin wrote:

Nah, thanks a lot for spotting that, I didn't

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-04 Thread via cfe-commits

https://github.com/kasuga-fj resolved 
https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-04 Thread via cfe-commits

https://github.com/kasuga-fj updated 
https://github.com/llvm/llvm-project/pull/65246:

>From d15196f5148194c5cb2f59c438d06f9fa61c8b4a Mon Sep 17 00:00:00 2001
From: "kasuga.ryotaro" 
Date: Wed, 30 Aug 2023 13:26:31 +0900
Subject: [PATCH 1/3] [Clang] Fix missing diagnostic for non-standard layout
 type in `offsetof`

Fixes #64619

Clang warns diagnostic for non-standard layout types in `offsetof` only
if they are in evaluated context. With this patch, you'll also get
  diagnostic if you use `offsetof` on non-standard layout types in any
  other contexts
---
 clang/lib/Sema/SemaExpr.cpp |  9 -
 clang/test/SemaCXX/class-layout.cpp | 30 ++---
 clang/test/SemaCXX/ms_struct.cpp|  5 ++---
 clang/test/SemaCXX/offsetof.cpp | 10 +-
 4 files changed, 26 insertions(+), 28 deletions(-)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index f9badf4ede847f..d78d823e15e62d 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -16750,12 +16750,11 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation 
BuiltinLoc,
 LangOpts.CPlusPlus11? diag::ext_offsetof_non_standardlayout_type
 : diag::ext_offsetof_non_pod_type;
 
-  if (!IsSafe && !DidWarnAboutNonPOD &&
-  DiagRuntimeBehavior(BuiltinLoc, nullptr,
-  PDiag(DiagID)
-  << SourceRange(Components[0].LocStart, OC.LocEnd)
-  << CurrentType))
+  if (!IsSafe && !DidWarnAboutNonPOD) {
+Diag(BuiltinLoc, DiagID)
+<< SourceRange(Components[0].LocStart, OC.LocEnd) << CurrentType;
 DidWarnAboutNonPOD = true;
+  }
 }
 
 // Look for the field.
diff --git a/clang/test/SemaCXX/class-layout.cpp 
b/clang/test/SemaCXX/class-layout.cpp
index 3ccd0ad25d7e75..a5660e10fe725a 100644
--- a/clang/test/SemaCXX/class-layout.cpp
+++ b/clang/test/SemaCXX/class-layout.cpp
@@ -1,18 +1,18 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++98 -Wno-inaccessible-base -Wno-c++11-extensions
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base
-// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple x86_64-scei-ps4%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-sie-ps5 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=6 -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=14 -DCLANG_ABI_COMPAT=14
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=16 -DCLANG_ABI_COMPAT=16
-// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 
-Wno-inaccessible-base
-// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 
-Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++98 -Wno-inaccessible-base -Wno-invalid-offsetof -Wno-c++11-extensions
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof
+// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple x86_64-scei-ps4%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -triple x86_64-sie-ps5 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -fclang-abi-compat=6 

[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-04 Thread Tobias Hieta via cfe-commits


@@ -39,6 +40,4 @@ struct C {
 
 static_assert(__builtin_offsetof(C, n) == 8,
   "long long field in ms_struct should be 8-byte aligned");
-#if !defined(TEST_FOR_ERROR) && !defined(TEST_FOR_WARNING)
-// expected-no-diagnostics
-#endif
+// expected-warning@-2 {{offset of on non-standard-layout type 'C'}}

tru wrote:

Ah I missed that it was in a test. We shouldn't run clang-format then. But the 
EOL should be fixed! Sorry for the drive-by review :)

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-04 Thread via cfe-commits


@@ -39,6 +40,4 @@ struct C {
 
 static_assert(__builtin_offsetof(C, n) == 8,
   "long long field in ms_struct should be 8-byte aligned");
-#if !defined(TEST_FOR_ERROR) && !defined(TEST_FOR_WARNING)
-// expected-no-diagnostics
-#endif
+// expected-warning@-2 {{offset of on non-standard-layout type 'C'}}

cor3ntin wrote:

We do not run clang-format on tests - in part because tests are sensible to 
line number changes.

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-04 Thread via cfe-commits


@@ -39,6 +40,4 @@ struct C {
 
 static_assert(__builtin_offsetof(C, n) == 8,
   "long long field in ms_struct should be 8-byte aligned");
-#if !defined(TEST_FOR_ERROR) && !defined(TEST_FOR_WARNING)
-// expected-no-diagnostics
-#endif
+// expected-warning@-2 {{offset of on non-standard-layout type 'C'}}

kasuga-fj wrote:

Yes. I ran `git clang-format HEAD~2`, but no files were modified. Should we 
apply clang-format to the tests as well? (I think removing EOL is not good. 
I'll fix it)

https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-04 Thread via cfe-commits

https://github.com/kasuga-fj edited 
https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-04 Thread via cfe-commits

https://github.com/kasuga-fj edited 
https://github.com/llvm/llvm-project/pull/65246
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits