[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

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

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-04-05 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman created https://github.com/llvm/llvm-project/pull/133472 This feature largely models the same behavior as in C++11. It is technically a breaking change between C99 and C11, so the paper is not being backported to older language modes. One difference between C++

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-04-05 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/133472 >From f9268b3a331fd8caf2440d742a1f084c0f9648ce Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Fri, 28 Mar 2025 13:01:58 -0400 Subject: [PATCH 1/3] [C11] Implement WG14 N1285 (temporary lifetimes) This

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-04-05 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 HEAD~1 HEAD --extensions c,h,cpp -- clang/test/C/C11/n1285_1.c clang/lib/CodeGen/CGDe

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-04-04 Thread A. Jiang via cfe-commits
frederick-vs-ja wrote: > (LMK if I've got that wrong!) Given that, how is the C11 change a breaking > change? It seems like the C99 rule was just bogus, and we should forget it > ever existed? IIUC, the "breaking change" is that in C99 a pointer value to a temporary array element never become

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-04-04 Thread Aaron Ballman via cfe-commits
@@ -0,0 +1,212 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 +// RUN: %clang_cc1 -std=c99 -Wno-dangling -emit-llvm -o - %s | FileCheck %s --check-prefix=C99 +// RUN: %clang_cc1 -std=c11 -Wno-dangling -emit-llvm -o - %s |

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-04-04 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/133472 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-04-04 Thread Eli Friedman via cfe-commits
@@ -27,7 +27,7 @@ void testva (int n, ...) { va_start(ap,n); // CHECK: [[AP:%[a-z0-9]+]] = alloca ptr, align 4 // CHECK: [[V5:%[a-z0-9]+]] = alloca %struct.x, align 4 - // CHECK: [[TMP:%[a-z0-9]+]] = alloca [4 x i32], align 4 + // CHECK: [[TMP:%[a-z0-9\.]+]] = alloca [4

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-04-04 Thread Aaron Ballman via cfe-commits
@@ -27,7 +27,7 @@ void testva (int n, ...) { va_start(ap,n); // CHECK: [[AP:%[a-z0-9]+]] = alloca ptr, align 4 // CHECK: [[V5:%[a-z0-9]+]] = alloca %struct.x, align 4 - // CHECK: [[TMP:%[a-z0-9]+]] = alloca [4 x i32], align 4 + // CHECK: [[TMP:%[a-z0-9\.]+]] = alloca [4

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-04-04 Thread A. Jiang via cfe-commits
frederick-vs-ja wrote: > That is unimplementable without dynamically allocating and leaking memory, > which we certainly should not do and which nobody would thank us for doing. Ah, I think [DR452](https://www.open-std.org/jtc1/sc22/wg14/issues/c11c17/issue0452.html) (adding "Such an object n

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

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

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

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

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

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

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

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

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-04-01 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/133472 >From f9268b3a331fd8caf2440d742a1f084c0f9648ce Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Fri, 28 Mar 2025 13:01:58 -0400 Subject: [PATCH 1/9] [C11] Implement WG14 N1285 (temporary lifetimes) This

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-03-31 Thread Eli Friedman via cfe-commits
@@ -0,0 +1,212 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 +// RUN: %clang_cc1 -std=c99 -Wno-dangling -emit-llvm -o - %s | FileCheck %s --check-prefix=C99 +// RUN: %clang_cc1 -std=c11 -Wno-dangling -emit-llvm -o - %s |

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-03-31 Thread James Y Knight via cfe-commits
jyknight wrote: - In C89: it's impossible to get the address of a temporary struct, so the lifetime is irrelevant. - In C99: you now can get the address (from an array subobject), but the lifetime was defined as "until the next sequence point". This made it technically illegal to access even n

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-03-31 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/133472 >From f9268b3a331fd8caf2440d742a1f084c0f9648ce Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Fri, 28 Mar 2025 13:01:58 -0400 Subject: [PATCH 1/8] [C11] Implement WG14 N1285 (temporary lifetimes) This

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-03-31 Thread Aaron Ballman via cfe-commits
@@ -27,7 +27,7 @@ void testva (int n, ...) { va_start(ap,n); // CHECK: [[AP:%[a-z0-9]+]] = alloca ptr, align 4 // CHECK: [[V5:%[a-z0-9]+]] = alloca %struct.x, align 4 - // CHECK: [[TMP:%[a-z0-9]+]] = alloca [4 x i32], align 4 + // CHECK: [[TMP:%[a-z0-9\.]+]] = alloca [4

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-03-31 Thread Eli Friedman via cfe-commits
@@ -27,7 +27,7 @@ void testva (int n, ...) { va_start(ap,n); // CHECK: [[AP:%[a-z0-9]+]] = alloca ptr, align 4 // CHECK: [[V5:%[a-z0-9]+]] = alloca %struct.x, align 4 - // CHECK: [[TMP:%[a-z0-9]+]] = alloca [4 x i32], align 4 + // CHECK: [[TMP:%[a-z0-9\.]+]] = alloca [4

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-03-31 Thread Aaron Ballman via cfe-commits
@@ -0,0 +1,212 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 +// RUN: %clang_cc1 -std=c99 -Wno-dangling -emit-llvm -o - %s | FileCheck %s --check-prefix=C99 +// RUN: %clang_cc1 -std=c11 -Wno-dangling -emit-llvm -o - %s |

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-03-31 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/133472 >From f9268b3a331fd8caf2440d742a1f084c0f9648ce Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Fri, 28 Mar 2025 13:01:58 -0400 Subject: [PATCH 1/7] [C11] Implement WG14 N1285 (temporary lifetimes) This

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-03-31 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/133472 >From f9268b3a331fd8caf2440d742a1f084c0f9648ce Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Fri, 28 Mar 2025 13:01:58 -0400 Subject: [PATCH 1/6] [C11] Implement WG14 N1285 (temporary lifetimes) This

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-03-31 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/133472 >From f9268b3a331fd8caf2440d742a1f084c0f9648ce Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Fri, 28 Mar 2025 13:01:58 -0400 Subject: [PATCH 1/5] [C11] Implement WG14 N1285 (temporary lifetimes) This

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-03-31 Thread Aaron Ballman via cfe-commits
@@ -741,10 +741,11 @@ ExprResult Sema::ImpCastExprToType(Expr *E, QualType Ty, if (Kind == CK_ArrayToPointerDecay) { // C++1z [conv.array]: The temporary materialization conversion is applied. // We also use this to fuel C++ DR1213, which applies to C++11 onwards. -

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-03-31 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/133472 >From f9268b3a331fd8caf2440d742a1f084c0f9648ce Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Fri, 28 Mar 2025 13:01:58 -0400 Subject: [PATCH 1/2] [C11] Implement WG14 N1285 (temporary lifetimes) This

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-03-28 Thread Eli Friedman via cfe-commits
@@ -0,0 +1,212 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 +// RUN: %clang_cc1 -std=c99 -Wno-dangling -emit-llvm -o - %s | FileCheck %s --check-prefix=C99 +// RUN: %clang_cc1 -std=c11 -Wno-dangling -emit-llvm -o - %s |

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-03-28 Thread Eli Friedman via cfe-commits
@@ -741,10 +741,11 @@ ExprResult Sema::ImpCastExprToType(Expr *E, QualType Ty, if (Kind == CK_ArrayToPointerDecay) { // C++1z [conv.array]: The temporary materialization conversion is applied. // We also use this to fuel C++ DR1213, which applies to C++11 onwards. -

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-03-28 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: Note, this will fail in precommit CI due to `test/CodeGenObjC/strong-in-c-struct.c`. I am posting this PR to see if there are other failures on Linux platforms that I'm missing locally, and to get an idea whether folks agree that this is heading in the right direction. I'm

[clang] [C11] Implement WG14 N1285 (temporary lifetimes) (PR #133472)

2025-03-28 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang @llvm/pr-subscribers-clang-codegen Author: Aaron Ballman (AaronBallman) Changes This feature largely models the same behavior as in C++11. It is technically a breaking change between C99 and C11, so the paper is not being backported to older lang