Skip to content

Commit

Permalink
Also run the capability qualifier test when compiling for C++
Browse files Browse the repository at this point in the history
  • Loading branch information
arichardson committed Jul 7, 2023
1 parent 649bdec commit 40b9240
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions clang/test/Sema/cheri/cheri-capability-qualifier-typedef.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
// RUN: %cheri_cc1 %s -fsyntax-only -verify
// RUN: %cheri_cc1 %s -fsyntax-only -verify=expected,c
// RUN: %cheri_cc1 -xc++ %s -fsyntax-only -verify=expected,cxx
// RUN: %cheri_cc1 -xc++ -Dtypeof=decltype %s -fsyntax-only -verify=expected,cxx

#ifdef __cplusplus
#define CHECK_SAME(a, b) static_assert(__is_same(a *, b *), "")
#else
#define CHECK_SAME(a, b) _Static_assert(__builtin_types_compatible_p(a *, b *), "")
#endif

#define _CONCAT(a, b) a##b
#define CONCAT(a, b) _CONCAT(a, b)
#define CHECK_TYPE(ty, expected) \
Expand Down Expand Up @@ -41,8 +48,11 @@ CHECK_TYPE(__capability scap *, struct s *__capability *);
CHECK_TYPE(scap __capability *, struct s *__capability *);

CHECK_TYPE(__capability s **, struct s *__capability *); // expected-error 2{{use of __capability is ambiguous}}
// expected-error@-1 3{{static_assert failed due to requirement '__builtin_types_compatible_p(struct s ***, struct s * __capability **)'}}
// c-error@-1 3{{static_assert failed due to requirement '__builtin_types_compatible_p(struct s ***, struct s * __capability **)'}}
// cxx-error@-2 3{{static_assert failed due to requirement '__is_same(s ***, s * __capability **)'}}
CHECK_TYPE(s __capability **, struct s *__capability *); // expected-error 2{{use of __capability is ambiguous}}
// expected-error@-1 3{{static_assert failed due to requirement '__builtin_types_compatible_p(struct s ***, struct s * __capability **)'}}
// c-error@-1 3{{static_assert failed due to requirement '__builtin_types_compatible_p(struct s ***, struct s * __capability **)'}}
// cxx-error@-2 3{{static_assert failed due to requirement '__is_same(s ***, s * __capability **)'}}
CHECK_TYPE(__capability s *__capability *, struct s *__capability *__capability); // expected-error 2 {{use of __capability is ambiguous}}
// expected-error@-1 3{{static_assert failed due to requirement '__builtin_types_compatible_p(struct s * __capability **, struct s * __capability * __capability *)'}}
// c-error@-1 3{{static_assert failed due to requirement '__builtin_types_compatible_p(struct s * __capability **, struct s * __capability * __capability *)'}}
// cxx-error@-2 3{{static_assert failed due to requirement '__is_same(s * __capability **, s * __capability * __capability *)'}}

0 comments on commit 40b9240

Please sign in to comment.