[clang] [Clang][Sema] Make _Imag int/float LValue not assignable (PR #218270)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 3 07:11:10 PDT 2026
================
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void lvalue_with_imag_int() {
+ int i;
+ __imag__ i = 0; // expected-error {{expression is not assignable}}
+}
+
+void lvalue_with_imag_float() {
+ float i;
+ __imag__ i = 0; // expected-error {{expression is not assignable}}
+}
+
+_Complex float foo()
+{
+ float f;
+ __real__ f = 0;
+ __imag__ f = 0; // expected-error {{expression is not assignable}}
+ return f;
+}
+
+_Complex float baz()
+{
+ float f;
+ __real__ f = 0;
+ __imag__ } // expected-error {{expected expression}}
----------------
AaronBallman wrote:
```suggestion
__imag__ // expected-error {{expected expression}}
}
```
https://github.com/llvm/llvm-project/pull/218270
More information about the cfe-commits
mailing list