https://github.com/mizvekov created https://github.com/llvm/llvm-project/pull/183972
Fixes #111300 >From c2a4e3f623d118b7049e60cff4c870e122f35e2f Mon Sep 17 00:00:00 2001 From: Matheus Izvekov <[email protected]> Date: Sat, 28 Feb 2026 21:20:25 -0300 Subject: [PATCH] [clang] fix common type calculation for l-values of 'void' type Fixes #111300 --- clang/lib/Sema/SemaExpr.cpp | 4 ++-- clang/test/Sema/sugar-common-types.c | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 2675d1680fc56..53d215f5c5e3e 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -8892,9 +8892,9 @@ QualType Sema::CheckConditionalOperands(ExprResult &Cond, ExprResult &LHS, // C99 6.5.15p5: "If both operands have void type, the result has void type." // The following || allows only one side to be void (a GCC-ism). if (LHSTy->isVoidType() || RHSTy->isVoidType()) { - QualType ResTy; if (LHSTy->isVoidType() && RHSTy->isVoidType()) { - ResTy = Context.getCommonSugaredType(LHSTy, RHSTy); + // UsualArithmeticConversions already handled the case where both sides + // are the same type. } else if (RHSTy->isVoidType()) { ResTy = RHSTy; Diag(RHS.get()->getBeginLoc(), diag::ext_typecheck_cond_one_void) diff --git a/clang/test/Sema/sugar-common-types.c b/clang/test/Sema/sugar-common-types.c index 54a6e3afed421..4fc345e9a2946 100644 --- a/clang/test/Sema/sugar-common-types.c +++ b/clang/test/Sema/sugar-common-types.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c99 -triple aarch64 -target-feature +bf16 -target-feature +sve +// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c99 -triple aarch64 -target-feature +bf16 -target-feature +sve -Wno-void-ptr-dereference typedef struct N {} N; @@ -42,3 +42,7 @@ void f8() { Y6 y6; N t8 = 0 ? x6 : y6; // expected-error {{incompatible type 'B6'}} } + +const volatile X2 *x7; +volatile Y2 *y7; +N t9 = 0 ? *x7 : *y7; // expected-error {{incompatible type 'B2'}} _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
