[clang] [Bounds Safety][NFC] Add some missing coverage for `-fexperimental-late-parse-attributes` (PR #102236)

Dan Liew via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 7 13:55:49 PDT 2024


https://github.com/delcypher updated https://github.com/llvm/llvm-project/pull/102236

>From 885d40de074514cf349423e7ae387ccdf6dfbbc4 Mon Sep 17 00:00:00 2001
From: Dan Liew <dan at su-root.co.uk>
Date: Tue, 6 Aug 2024 14:38:16 -0700
Subject: [PATCH 1/2] [Bounds Safety][NFC] Add some missing coverage for
 `-fexperimental-late-parse-attributes`

Previously we weren't properly checking that using
`-fexperimental-late-parse-attributes` worked on source code that
didn't need late parsing.

For example we weren't testing that the attribute appearing in the type
position generated the right AST with
`-fexperimental-late-parse-attributes` on or off.

This patch adds additional `RUN` lines to re-run the relevant test
cases with `-fexperimental-late-parse-attributes` enabled.

rdar://133325597
---
 clang/test/AST/attr-counted-by-or-null-struct-ptrs.c   |  1 +
 clang/test/AST/attr-counted-by-struct-ptrs.c           |  1 +
 clang/test/AST/attr-sized-by-or-null-struct-ptrs.c     |  1 +
 clang/test/AST/attr-sized-by-struct-ptrs.c             |  1 +
 clang/test/Sema/attr-counted-by-bounds-safety-vlas.c   |  1 +
 clang/test/Sema/attr-counted-by-or-null-last-field.c   |  8 ++++++++
 ...ttr-counted-by-or-null-struct-ptrs-sizeless-types.c |  1 +
 clang/test/Sema/attr-counted-by-or-null-struct-ptrs.c  |  1 +
 .../Sema/attr-counted-by-or-null-vla-sizeless-types.c  |  1 +
 .../Sema/attr-counted-by-struct-ptrs-sizeless-types.c  |  1 +
 clang/test/Sema/attr-counted-by-struct-ptrs.c          |  3 +++
 clang/test/Sema/attr-counted-by-vla-sizeless-types.c   |  1 +
 clang/test/Sema/attr-counted-by-vla.c                  | 10 ++++++++++
 clang/test/Sema/attr-sized-by-last-field.c             |  8 ++++++++
 clang/test/Sema/attr-sized-by-or-null-last-field.c     |  8 ++++++++
 .../attr-sized-by-or-null-struct-ptrs-sizeless-types.c |  1 +
 clang/test/Sema/attr-sized-by-or-null-struct-ptrs.c    |  1 +
 .../Sema/attr-sized-by-or-null-vla-sizeless-types.c    |  1 +
 .../Sema/attr-sized-by-struct-ptrs-sizeless-types.c    |  1 +
 clang/test/Sema/attr-sized-by-struct-ptrs.c            |  1 +
 clang/test/Sema/attr-sized-by-vla-sizeless-types.c     |  1 +
 21 files changed, 53 insertions(+)

diff --git a/clang/test/AST/attr-counted-by-or-null-struct-ptrs.c b/clang/test/AST/attr-counted-by-or-null-struct-ptrs.c
index cedb3f1192eda..075f583784fe1 100644
--- a/clang/test/AST/attr-counted-by-or-null-struct-ptrs.c
+++ b/clang/test/AST/attr-counted-by-or-null-struct-ptrs.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -ast-dump | FileCheck %s
+// RUN: %clang_cc1 -fexperimental-late-parse-attributes %s -ast-dump | FileCheck %s
 
 #define __counted_by_or_null(f)  __attribute__((counted_by_or_null(f)))
 
diff --git a/clang/test/AST/attr-counted-by-struct-ptrs.c b/clang/test/AST/attr-counted-by-struct-ptrs.c
index 79a453d239cd5..0c05258234143 100644
--- a/clang/test/AST/attr-counted-by-struct-ptrs.c
+++ b/clang/test/AST/attr-counted-by-struct-ptrs.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -ast-dump | FileCheck %s
+// RUN: %clang_cc1 -fexperimental-late-parse-attributes %s -ast-dump | FileCheck %s
 
 #define __counted_by(f)  __attribute__((counted_by(f)))
 
diff --git a/clang/test/AST/attr-sized-by-or-null-struct-ptrs.c b/clang/test/AST/attr-sized-by-or-null-struct-ptrs.c
index 6189799b85ccb..73b8a71f23503 100644
--- a/clang/test/AST/attr-sized-by-or-null-struct-ptrs.c
+++ b/clang/test/AST/attr-sized-by-or-null-struct-ptrs.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -ast-dump | FileCheck %s
+// RUN: %clang_cc1 -fexperimental-late-parse-attributes %s -ast-dump | FileCheck %s
 
 #define __sized_by_or_null(f)  __attribute__((sized_by_or_null(f)))
 
diff --git a/clang/test/AST/attr-sized-by-struct-ptrs.c b/clang/test/AST/attr-sized-by-struct-ptrs.c
index 5d9ed0094c685..7f7e3dfea2ac7 100644
--- a/clang/test/AST/attr-sized-by-struct-ptrs.c
+++ b/clang/test/AST/attr-sized-by-struct-ptrs.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -ast-dump | FileCheck %s
+// RUN: %clang_cc1 -fexperimental-late-parse-attributes %s -ast-dump | FileCheck %s
 
 #define __sized_by(f)  __attribute__((sized_by(f)))
 
diff --git a/clang/test/Sema/attr-counted-by-bounds-safety-vlas.c b/clang/test/Sema/attr-counted-by-bounds-safety-vlas.c
index 7d9c9a90880ff..5a739f9c6bc04 100644
--- a/clang/test/Sema/attr-counted-by-bounds-safety-vlas.c
+++ b/clang/test/Sema/attr-counted-by-bounds-safety-vlas.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -fexperimental-bounds-safety -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fexperimental-bounds-safety -fexperimental-late-parse-attributes -verify %s
 //
 // This is a portion of the `attr-counted-by-vla.c` test but is checked
 // under the semantics of `-fexperimental-bounds-safety` which has different
diff --git a/clang/test/Sema/attr-counted-by-or-null-last-field.c b/clang/test/Sema/attr-counted-by-or-null-last-field.c
index dd3a6422521c0..c906b4b6c4b07 100644
--- a/clang/test/Sema/attr-counted-by-or-null-last-field.c
+++ b/clang/test/Sema/attr-counted-by-or-null-last-field.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DLATE_PARSING_ENABLED -fsyntax-only -fexperimental-late-parse-attributes -verify %s
 
 #define __counted_by_or_null(f)  __attribute__((counted_by_or_null(f)))
 
@@ -80,10 +81,17 @@ struct found_outside_of_struct {
   struct bar ** ptr __counted_by_or_null(global); // expected-error {{field 'global' in 'counted_by_or_null' not inside structure}}
 };
 
+#ifndef LATE_PARSING_ENABLED
 struct self_referrential {
   int bork;
   struct bar *self[] __counted_by_or_null(self); // expected-error {{use of undeclared identifier 'self'}}
 };
+#else
+struct self_referrential {
+  int bork;
+  struct bar *self[] __counted_by_or_null(self); // expected-error {{'counted_by_or_null' only applies to pointers; did you mean to use 'counted_by'?}}
+};
+#endif
 
 struct non_int_count {
   double dbl_count;
diff --git a/clang/test/Sema/attr-counted-by-or-null-struct-ptrs-sizeless-types.c b/clang/test/Sema/attr-counted-by-or-null-struct-ptrs-sizeless-types.c
index 301977300b06a..4b898e7369c19 100644
--- a/clang/test/Sema/attr-counted-by-or-null-struct-ptrs-sizeless-types.c
+++ b/clang/test/Sema/attr-counted-by-or-null-struct-ptrs-sizeless-types.c
@@ -1,5 +1,6 @@
 // __SVInt8_t is specific to ARM64 so specify that in the target triple
 // RUN: %clang_cc1 -triple arm64-apple-darwin -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fexperimental-late-parse-attributes -triple arm64-apple-darwin -fsyntax-only -verify %s
 
 #define __counted_by_or_null(f)  __attribute__((counted_by_or_null(f)))
 
diff --git a/clang/test/Sema/attr-counted-by-or-null-struct-ptrs.c b/clang/test/Sema/attr-counted-by-or-null-struct-ptrs.c
index 017aafe0c9396..708bb727ce09d 100644
--- a/clang/test/Sema/attr-counted-by-or-null-struct-ptrs.c
+++ b/clang/test/Sema/attr-counted-by-or-null-struct-ptrs.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fexperimental-late-parse-attributes -fsyntax-only -verify %s
 
 #define __counted_by_or_null(f)  __attribute__((counted_by_or_null(f)))
 #define __counted_by(f)  __attribute__((counted_by(f)))
diff --git a/clang/test/Sema/attr-counted-by-or-null-vla-sizeless-types.c b/clang/test/Sema/attr-counted-by-or-null-vla-sizeless-types.c
index 8abd4476fe597..1e8c7179e7903 100644
--- a/clang/test/Sema/attr-counted-by-or-null-vla-sizeless-types.c
+++ b/clang/test/Sema/attr-counted-by-or-null-vla-sizeless-types.c
@@ -1,5 +1,6 @@
 // __SVInt8_t is specific to ARM64 so specify that in the target triple
 // RUN: %clang_cc1 -triple arm64-apple-darwin -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fexperimental-late-parse-attributes -triple arm64-apple-darwin -fsyntax-only -verify %s
 
 #define __counted_by_or_null(f)  __attribute__((counted_by_or_null(f)))
 
diff --git a/clang/test/Sema/attr-counted-by-struct-ptrs-sizeless-types.c b/clang/test/Sema/attr-counted-by-struct-ptrs-sizeless-types.c
index 9b0f2eafb13c2..1de93640cf458 100644
--- a/clang/test/Sema/attr-counted-by-struct-ptrs-sizeless-types.c
+++ b/clang/test/Sema/attr-counted-by-struct-ptrs-sizeless-types.c
@@ -1,5 +1,6 @@
 // __SVInt8_t is specific to ARM64 so specify that in the target triple
 // RUN: %clang_cc1 -triple arm64-apple-darwin -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fexperimental-late-parse-attributes -triple arm64-apple-darwin -fsyntax-only -verify %s
 
 #define __counted_by(f)  __attribute__((counted_by(f)))
 
diff --git a/clang/test/Sema/attr-counted-by-struct-ptrs.c b/clang/test/Sema/attr-counted-by-struct-ptrs.c
index cd2bfe36938b2..a35d4fcf02a58 100644
--- a/clang/test/Sema/attr-counted-by-struct-ptrs.c
+++ b/clang/test/Sema/attr-counted-by-struct-ptrs.c
@@ -1,4 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// Test that in late parsing mode attributes that don't require late parsing
+// are handled correctly
+// RUN: %clang_cc1 -fsyntax-only -fexperimental-late-parse-attributes %s -verify
 
 #define __counted_by(f)  __attribute__((counted_by(f)))
 
diff --git a/clang/test/Sema/attr-counted-by-vla-sizeless-types.c b/clang/test/Sema/attr-counted-by-vla-sizeless-types.c
index 31c0007501c48..8cc5f64482548 100644
--- a/clang/test/Sema/attr-counted-by-vla-sizeless-types.c
+++ b/clang/test/Sema/attr-counted-by-vla-sizeless-types.c
@@ -1,5 +1,6 @@
 // __SVInt8_t is specific to ARM64 so specify that in the target triple
 // RUN: %clang_cc1 -triple arm64-apple-darwin -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple arm64-apple-darwin -fexperimental-late-parse-attributes -fsyntax-only -verify %s
 
 #define __counted_by(f)  __attribute__((counted_by(f)))
 
diff --git a/clang/test/Sema/attr-counted-by-vla.c b/clang/test/Sema/attr-counted-by-vla.c
index 571d6e6291e6b..de450944211ec 100644
--- a/clang/test/Sema/attr-counted-by-vla.c
+++ b/clang/test/Sema/attr-counted-by-vla.c
@@ -1,4 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// Test that in late parsing mode attributes that don't require late parsing
+// still parse correctly.
+// RUN: %clang_cc1 -DLATE_PARSING_ENABLED -fsyntax-only -fexperimental-late-parse-attributes %s -verify
 
 #define __counted_by(f)  __attribute__((counted_by(f)))
 
@@ -78,10 +81,17 @@ struct found_outside_of_struct {
   struct bar *fam[] __counted_by(global); // expected-error {{field 'global' in 'counted_by' not inside structure}}
 };
 
+#ifndef LATE_PARSING_ENABLED
 struct self_referrential {
   int bork;
   struct bar *self[] __counted_by(self); // expected-error {{use of undeclared identifier 'self'}}
 };
+#else
+struct self_referrential {
+  int bork;
+  struct bar *self[] __counted_by(self); // expected-error {{'counted_by' requires a non-boolean integer type argument}}
+};
+#endif
 
 struct non_int_count {
   double dbl_count;
diff --git a/clang/test/Sema/attr-sized-by-last-field.c b/clang/test/Sema/attr-sized-by-last-field.c
index 6af29e9f31435..35be22f888939 100644
--- a/clang/test/Sema/attr-sized-by-last-field.c
+++ b/clang/test/Sema/attr-sized-by-last-field.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DLATE_PARSING_ENABLED -fexperimental-late-parse-attributes -fsyntax-only -verify %s
 
 #define __sized_by(f)  __attribute__((sized_by(f)))
 
@@ -80,10 +81,17 @@ struct found_outside_of_struct {
   struct bar ** ptr __sized_by(global); // expected-error {{field 'global' in 'sized_by' not inside structure}}
 };
 
+#ifndef LATE_PARSING_ENABLED
 struct self_referrential {
   int bork;
   struct bar *self[] __sized_by(self); // expected-error {{use of undeclared identifier 'self'}}
 };
+#else
+struct self_referrential {
+  int bork;
+  struct bar *self[] __sized_by(self); // expected-error {{'sized_by' only applies to pointers; did you mean to use 'counted_by'?}}
+};
+#endif
 
 struct non_int_size {
   double dbl_size;
diff --git a/clang/test/Sema/attr-sized-by-or-null-last-field.c b/clang/test/Sema/attr-sized-by-or-null-last-field.c
index 96bbe847b910b..7322a7d9f6c25 100644
--- a/clang/test/Sema/attr-sized-by-or-null-last-field.c
+++ b/clang/test/Sema/attr-sized-by-or-null-last-field.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DLATE_PARSING_ENABLED -fsyntax-only -fexperimental-late-parse-attributes -verify %s
 
 #define __sized_by_or_null(f)  __attribute__((sized_by_or_null(f)))
 
@@ -80,10 +81,17 @@ struct found_outside_of_struct {
   struct bar ** ptr __sized_by_or_null(global); // expected-error {{field 'global' in 'sized_by_or_null' not inside structure}}
 };
 
+#ifndef LATE_PARSING_ENABLED
 struct self_referrential {
   int bork;
   struct bar *self[] __sized_by_or_null(self); // expected-error {{use of undeclared identifier 'self'}}
 };
+#else
+struct self_referrential {
+  int bork;
+  struct bar *self[] __sized_by_or_null(self); // expected-error {{'sized_by_or_null' only applies to pointers; did you mean to use 'counted_by'?}}
+};
+#endif
 
 struct non_int_size {
   double dbl_size;
diff --git a/clang/test/Sema/attr-sized-by-or-null-struct-ptrs-sizeless-types.c b/clang/test/Sema/attr-sized-by-or-null-struct-ptrs-sizeless-types.c
index 4a360b9722a0b..d960c0d31b65c 100644
--- a/clang/test/Sema/attr-sized-by-or-null-struct-ptrs-sizeless-types.c
+++ b/clang/test/Sema/attr-sized-by-or-null-struct-ptrs-sizeless-types.c
@@ -1,5 +1,6 @@
 // __SVInt8_t is specific to ARM64 so specify that in the target triple
 // RUN: %clang_cc1 -triple arm64-apple-darwin -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fexperimental-late-parse-attributes -triple arm64-apple-darwin -fsyntax-only -verify %s
 
 #define __sized_by_or_null(f)  __attribute__((sized_by_or_null(f)))
 
diff --git a/clang/test/Sema/attr-sized-by-or-null-struct-ptrs.c b/clang/test/Sema/attr-sized-by-or-null-struct-ptrs.c
index 2c7578b5ecbe6..4200c9275a180 100644
--- a/clang/test/Sema/attr-sized-by-or-null-struct-ptrs.c
+++ b/clang/test/Sema/attr-sized-by-or-null-struct-ptrs.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fexperimental-late-parse-attributes -fsyntax-only -verify %s
 
 #define __sized_by_or_null(f)  __attribute__((sized_by_or_null(f)))
 #define __counted_by(f)  __attribute__((counted_by(f)))
diff --git a/clang/test/Sema/attr-sized-by-or-null-vla-sizeless-types.c b/clang/test/Sema/attr-sized-by-or-null-vla-sizeless-types.c
index 398b1df592fe3..7d16c2d456a02 100644
--- a/clang/test/Sema/attr-sized-by-or-null-vla-sizeless-types.c
+++ b/clang/test/Sema/attr-sized-by-or-null-vla-sizeless-types.c
@@ -1,5 +1,6 @@
 // __SVInt8_t is specific to ARM64 so specify that in the target triple
 // RUN: %clang_cc1 -triple arm64-apple-darwin -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fexperimental-late-parse-attributes -triple arm64-apple-darwin -fsyntax-only -verify %s
 
 #define __sized_by_or_null(f)  __attribute__((sized_by_or_null(f)))
 
diff --git a/clang/test/Sema/attr-sized-by-struct-ptrs-sizeless-types.c b/clang/test/Sema/attr-sized-by-struct-ptrs-sizeless-types.c
index 2e916bdb04720..7038330e60eee 100644
--- a/clang/test/Sema/attr-sized-by-struct-ptrs-sizeless-types.c
+++ b/clang/test/Sema/attr-sized-by-struct-ptrs-sizeless-types.c
@@ -1,5 +1,6 @@
 // __SVInt8_t is specific to ARM64 so specify that in the target triple
 // RUN: %clang_cc1 -triple arm64-apple-darwin -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fexperimental-late-parse-attributes -triple arm64-apple-darwin -fsyntax-only -verify %s
 
 #define __sized_by(f)  __attribute__((sized_by(f)))
 
diff --git a/clang/test/Sema/attr-sized-by-struct-ptrs.c b/clang/test/Sema/attr-sized-by-struct-ptrs.c
index 01195469c6fe4..07373b247d0f7 100644
--- a/clang/test/Sema/attr-sized-by-struct-ptrs.c
+++ b/clang/test/Sema/attr-sized-by-struct-ptrs.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fexperimental-late-parse-attributes -fsyntax-only -verify %s
 
 #define __sized_by(f)  __attribute__((sized_by(f)))
 #define __counted_by(f)  __attribute__((counted_by(f)))
diff --git a/clang/test/Sema/attr-sized-by-vla-sizeless-types.c b/clang/test/Sema/attr-sized-by-vla-sizeless-types.c
index 37e91639bb4a1..8a94b1217c906 100644
--- a/clang/test/Sema/attr-sized-by-vla-sizeless-types.c
+++ b/clang/test/Sema/attr-sized-by-vla-sizeless-types.c
@@ -1,5 +1,6 @@
 // __SVInt8_t is specific to ARM64 so specify that in the target triple
 // RUN: %clang_cc1 -triple arm64-apple-darwin -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fexperimental-late-parse-attributes -triple arm64-apple-darwin -fsyntax-only -verify %s
 
 #define __sized_by(f)  __attribute__((sized_by(f)))
 

>From a12ee19febd7f942548a7080c6db641019fd51eb Mon Sep 17 00:00:00 2001
From: Dan Liew <dan at su-root.co.uk>
Date: Wed, 7 Aug 2024 13:52:14 -0700
Subject: [PATCH 2/2] Address Aaron's feedback and remove some unneeded
 comments

---
 .../Sema/attr-counted-by-or-null-last-field.c   | 15 +++++----------
 clang/test/Sema/attr-counted-by-struct-ptrs.c   |  2 --
 clang/test/Sema/attr-counted-by-vla.c           | 17 +++++------------
 clang/test/Sema/attr-sized-by-last-field.c      | 15 +++++----------
 .../Sema/attr-sized-by-or-null-last-field.c     | 15 +++++----------
 5 files changed, 20 insertions(+), 44 deletions(-)

diff --git a/clang/test/Sema/attr-counted-by-or-null-last-field.c b/clang/test/Sema/attr-counted-by-or-null-last-field.c
index c906b4b6c4b07..12c0b6de44f72 100644
--- a/clang/test/Sema/attr-counted-by-or-null-last-field.c
+++ b/clang/test/Sema/attr-counted-by-or-null-last-field.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -DLATE_PARSING_ENABLED -fsyntax-only -fexperimental-late-parse-attributes -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,immediate %s
+// RUN: %clang_cc1 -fsyntax-only -fexperimental-late-parse-attributes -verify=expected,late %s
 
 #define __counted_by_or_null(f)  __attribute__((counted_by_or_null(f)))
 
@@ -81,17 +81,12 @@ struct found_outside_of_struct {
   struct bar ** ptr __counted_by_or_null(global); // expected-error {{field 'global' in 'counted_by_or_null' not inside structure}}
 };
 
-#ifndef LATE_PARSING_ENABLED
 struct self_referrential {
   int bork;
-  struct bar *self[] __counted_by_or_null(self); // expected-error {{use of undeclared identifier 'self'}}
+  // immediate-error at +2{{use of undeclared identifier 'self'}}
+  // late-error at +1{{'counted_by_or_null' only applies to pointers; did you mean to use 'counted_by'?}}
+  struct bar *self[] __counted_by_or_null(self);
 };
-#else
-struct self_referrential {
-  int bork;
-  struct bar *self[] __counted_by_or_null(self); // expected-error {{'counted_by_or_null' only applies to pointers; did you mean to use 'counted_by'?}}
-};
-#endif
 
 struct non_int_count {
   double dbl_count;
diff --git a/clang/test/Sema/attr-counted-by-struct-ptrs.c b/clang/test/Sema/attr-counted-by-struct-ptrs.c
index a35d4fcf02a58..321d6aafbeba2 100644
--- a/clang/test/Sema/attr-counted-by-struct-ptrs.c
+++ b/clang/test/Sema/attr-counted-by-struct-ptrs.c
@@ -1,6 +1,4 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
-// Test that in late parsing mode attributes that don't require late parsing
-// are handled correctly
 // RUN: %clang_cc1 -fsyntax-only -fexperimental-late-parse-attributes %s -verify
 
 #define __counted_by(f)  __attribute__((counted_by(f)))
diff --git a/clang/test/Sema/attr-counted-by-vla.c b/clang/test/Sema/attr-counted-by-vla.c
index de450944211ec..35737c03f3222 100644
--- a/clang/test/Sema/attr-counted-by-vla.c
+++ b/clang/test/Sema/attr-counted-by-vla.c
@@ -1,7 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-// Test that in late parsing mode attributes that don't require late parsing
-// still parse correctly.
-// RUN: %clang_cc1 -DLATE_PARSING_ENABLED -fsyntax-only -fexperimental-late-parse-attributes %s -verify
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,immediate %s
+// RUN: %clang_cc1 -fsyntax-only -fexperimental-late-parse-attributes %s -verify=expected,late
 
 #define __counted_by(f)  __attribute__((counted_by(f)))
 
@@ -81,17 +79,12 @@ struct found_outside_of_struct {
   struct bar *fam[] __counted_by(global); // expected-error {{field 'global' in 'counted_by' not inside structure}}
 };
 
-#ifndef LATE_PARSING_ENABLED
 struct self_referrential {
   int bork;
-  struct bar *self[] __counted_by(self); // expected-error {{use of undeclared identifier 'self'}}
+  // immediate-error at +2{{use of undeclared identifier 'self'}}
+  // late-error at +1{{'counted_by' requires a non-boolean integer type argument}}
+  struct bar *self[] __counted_by(self);
 };
-#else
-struct self_referrential {
-  int bork;
-  struct bar *self[] __counted_by(self); // expected-error {{'counted_by' requires a non-boolean integer type argument}}
-};
-#endif
 
 struct non_int_count {
   double dbl_count;
diff --git a/clang/test/Sema/attr-sized-by-last-field.c b/clang/test/Sema/attr-sized-by-last-field.c
index 35be22f888939..f2e74f7fdf4b5 100644
--- a/clang/test/Sema/attr-sized-by-last-field.c
+++ b/clang/test/Sema/attr-sized-by-last-field.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -DLATE_PARSING_ENABLED -fexperimental-late-parse-attributes -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,immediate %s
+// RUN: %clang_cc1 -fexperimental-late-parse-attributes -fsyntax-only -verify=expected,late %s
 
 #define __sized_by(f)  __attribute__((sized_by(f)))
 
@@ -81,17 +81,12 @@ struct found_outside_of_struct {
   struct bar ** ptr __sized_by(global); // expected-error {{field 'global' in 'sized_by' not inside structure}}
 };
 
-#ifndef LATE_PARSING_ENABLED
 struct self_referrential {
   int bork;
-  struct bar *self[] __sized_by(self); // expected-error {{use of undeclared identifier 'self'}}
+  // immediate-error at +2{{use of undeclared identifier 'self'}}
+  // late-error at +1{{'sized_by' only applies to pointers; did you mean to use 'counted_by'?}}
+  struct bar *self[] __sized_by(self);
 };
-#else
-struct self_referrential {
-  int bork;
-  struct bar *self[] __sized_by(self); // expected-error {{'sized_by' only applies to pointers; did you mean to use 'counted_by'?}}
-};
-#endif
 
 struct non_int_size {
   double dbl_size;
diff --git a/clang/test/Sema/attr-sized-by-or-null-last-field.c b/clang/test/Sema/attr-sized-by-or-null-last-field.c
index 7322a7d9f6c25..08ef5263a05cf 100644
--- a/clang/test/Sema/attr-sized-by-or-null-last-field.c
+++ b/clang/test/Sema/attr-sized-by-or-null-last-field.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -DLATE_PARSING_ENABLED -fsyntax-only -fexperimental-late-parse-attributes -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,immediate %s
+// RUN: %clang_cc1 -fsyntax-only -fexperimental-late-parse-attributes -verify=expected,late %s
 
 #define __sized_by_or_null(f)  __attribute__((sized_by_or_null(f)))
 
@@ -81,17 +81,12 @@ struct found_outside_of_struct {
   struct bar ** ptr __sized_by_or_null(global); // expected-error {{field 'global' in 'sized_by_or_null' not inside structure}}
 };
 
-#ifndef LATE_PARSING_ENABLED
 struct self_referrential {
   int bork;
-  struct bar *self[] __sized_by_or_null(self); // expected-error {{use of undeclared identifier 'self'}}
+  // immediate-error at +2{{use of undeclared identifier 'self'}}
+  // late-error at +1{{'sized_by_or_null' only applies to pointers; did you mean to use 'counted_by'?}}
+  struct bar *self[] __sized_by_or_null(self);
 };
-#else
-struct self_referrential {
-  int bork;
-  struct bar *self[] __sized_by_or_null(self); // expected-error {{'sized_by_or_null' only applies to pointers; did you mean to use 'counted_by'?}}
-};
-#endif
 
 struct non_int_size {
   double dbl_size;



More information about the cfe-commits mailing list