[PATCH] D158702: [clang][Interp] Check pointer inc/dec ops for initialization

2023-09-15 Thread Timm Bäder via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG177f9ab2fbd8: [clang][Interp] Check pointer inc/dec ops for 
initialization (authored by tbaeder).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158702/new/

https://reviews.llvm.org/D158702

Files:
  clang/lib/AST/Interp/Interp.h
  clang/test/AST/Interp/literals.cpp

Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -509,36 +509,72 @@
   }
   static_assert(incBool(), "");
 
-  template
+  /// FIXME: The diagnostics for pre-inc/dec of pointers doesn't match the
+  /// current interpreter. But they are stil OK.
+  template
   constexpr int uninit() {
 T a;
-if constexpr (Inc)
-  ++a; // ref-note 2{{increment of uninitialized}} \
-   // expected-note 2{{increment of uninitialized}}
-else
-  --a; // ref-note 2{{decrement of uninitialized}} \
-   // expected-note 2{{decrement of uninitialized}}
+if constexpr (Inc) {
+  if (Pre)
+++a; // ref-note 3{{increment of uninitialized}} \
+ // expected-note 2{{increment of uninitialized}} \
+ // expected-note {{read of uninitialized}}
+  else
+a++; // ref-note 2{{increment of uninitialized}} \
+ // expected-note 2{{increment of uninitialized}}
+} else {
+  if (Pre)
+--a; // ref-note 3{{decrement of uninitialized}} \
+ // expected-note 2{{decrement of uninitialized}} \
+ // expected-note {{read of uninitialized}}
+  else
+a--; // ref-note 2{{decrement of uninitialized}} \
+ // expected-note 2{{decrement of uninitialized}}
+}
 return 1;
   }
-  static_assert(uninit(), ""); // ref-error {{not an integral constant expression}} \
-  // ref-note {{in call to 'uninit()'}} \
-  // expected-error {{not an integral constant expression}} \
-  // expected-note {{in call to 'uninit()'}}
-
-  static_assert(uninit(), ""); // ref-error {{not an integral constant expression}} \
-   // ref-note {{in call to 'uninit()'}} \
-   // expected-error {{not an integral constant expression}} \
-   // expected-note {{in call to 'uninit()'}}
-
-  static_assert(uninit(), ""); // ref-error {{not an integral constant expression}} \
-// ref-note {{in call to 'uninit()'}} \
-// expected-error {{not an integral constant expression}} \
-// expected-note {{in call to 'uninit()'}}
-
-  static_assert(uninit(), ""); // ref-error {{not an integral constant expression}} \
- // ref-note {{in call to 'uninit()'}} \
- // expected-error {{not an integral constant expression}} \
- // expected-note {{in call to 'uninit()'}}
+  static_assert(uninit(), ""); // ref-error {{not an integral constant expression}} \
+// ref-note {{in call to 'uninit()'}} \
+// expected-error {{not an integral constant expression}} \
+// expected-note {{in call to 'uninit()'}}
+  static_assert(uninit(), ""); // ref-error {{not an integral constant expression}} \
+ // ref-note {{in call to 'uninit()'}} \
+ // expected-error {{not an integral constant expression}} \
+ // expected-note {{in call to 'uninit()'}}
+
+  static_assert(uninit(), ""); // ref-error {{not an integral constant expression}} \
+  // ref-note {{in call to 'uninit()'}} \
+  // expected-error {{not an integral constant expression}} \
+  // expected-note {{in call to 'uninit()'}}
+  static_assert(uninit(), ""); // ref-error {{not an integral constant expression}} \
+   // ref-note {{in call to 'uninit()'}} \
+   // expected-error {{not an integral constant expression}} \
+   // expected-note {{in call to 'uninit()'}}
+  static_assert(uninit(), ""); // ref-error {{not an integral constant expression}} \
+  

[PATCH] D158702: [clang][Interp] Check pointer inc/dec ops for initialization

2023-09-07 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin accepted this revision.
cor3ntin added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158702/new/

https://reviews.llvm.org/D158702

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D158702: [clang][Interp] Check pointer inc/dec ops for initialization

2023-08-31 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158702/new/

https://reviews.llvm.org/D158702

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D158702: [clang][Interp] Check pointer inc/dec ops for initialization

2023-08-23 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, erichkeane, shafik, cor3ntin.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158702

Files:
  clang/lib/AST/Interp/Interp.h
  clang/test/AST/Interp/literals.cpp

Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -523,36 +523,72 @@
   }
   static_assert(incBool(), "");
 
-  template
+  /// FIXME: The diagnostics for pre-inc/dec of pointers doesn't match the
+  /// current interpreter. But they are stil OK.
+  template
   constexpr int uninit() {
 T a;
-if constexpr (Inc)
-  ++a; // ref-note 2{{increment of uninitialized}} \
-   // expected-note 2{{increment of uninitialized}}
-else
-  --a; // ref-note 2{{decrement of uninitialized}} \
-   // expected-note 2{{decrement of uninitialized}}
+if constexpr (Inc) {
+  if (Pre)
+++a; // ref-note 3{{increment of uninitialized}} \
+ // expected-note 2{{increment of uninitialized}} \
+ // expected-note {{read of uninitialized}}
+  else
+a++; // ref-note 2{{increment of uninitialized}} \
+ // expected-note 2{{increment of uninitialized}}
+} else {
+  if (Pre)
+--a; // ref-note 3{{decrement of uninitialized}} \
+ // expected-note 2{{decrement of uninitialized}} \
+ // expected-note {{read of uninitialized}}
+  else
+a--; // ref-note 2{{decrement of uninitialized}} \
+ // expected-note 2{{decrement of uninitialized}}
+}
 return 1;
   }
-  static_assert(uninit(), ""); // ref-error {{not an integral constant expression}} \
-  // ref-note {{in call to 'uninit()'}} \
-  // expected-error {{not an integral constant expression}} \
-  // expected-note {{in call to 'uninit()'}}
-
-  static_assert(uninit(), ""); // ref-error {{not an integral constant expression}} \
-   // ref-note {{in call to 'uninit()'}} \
-   // expected-error {{not an integral constant expression}} \
-   // expected-note {{in call to 'uninit()'}}
-
-  static_assert(uninit(), ""); // ref-error {{not an integral constant expression}} \
-// ref-note {{in call to 'uninit()'}} \
-// expected-error {{not an integral constant expression}} \
-// expected-note {{in call to 'uninit()'}}
-
-  static_assert(uninit(), ""); // ref-error {{not an integral constant expression}} \
- // ref-note {{in call to 'uninit()'}} \
- // expected-error {{not an integral constant expression}} \
- // expected-note {{in call to 'uninit()'}}
+  static_assert(uninit(), ""); // ref-error {{not an integral constant expression}} \
+// ref-note {{in call to 'uninit()'}} \
+// expected-error {{not an integral constant expression}} \
+// expected-note {{in call to 'uninit()'}}
+  static_assert(uninit(), ""); // ref-error {{not an integral constant expression}} \
+ // ref-note {{in call to 'uninit()'}} \
+ // expected-error {{not an integral constant expression}} \
+ // expected-note {{in call to 'uninit()'}}
+
+  static_assert(uninit(), ""); // ref-error {{not an integral constant expression}} \
+  // ref-note {{in call to 'uninit()'}} \
+  // expected-error {{not an integral constant expression}} \
+  // expected-note {{in call to 'uninit()'}}
+  static_assert(uninit(), ""); // ref-error {{not an integral constant expression}} \
+   // ref-note {{in call to 'uninit()'}} \
+   // expected-error {{not an integral constant expression}} \
+   // expected-note {{in call to 'uninit()'}}
+  static_assert(uninit(), ""); // ref-error {{not an integral constant expression}} \
+   // ref-note {{in call to