================
@@ -0,0 +1,178 @@
+// RUN: %clang_cc1 %s -Winteger-overflow -Wno-unused-value
-fexperimental-overflow-behavior-types -Wconstant-conversion
-Woverflow-behavior-conversion -verify -fsyntax-only
+
+typedef int __attribute__((overflow_behavior)) bad_arg_count; //
expected-error {{'overflow_behavior' attribute takes one argument}}
+typedef int __attribute__((overflow_behavior(not_real))) bad_arg_spec; //
expected-error {{'not_real' is not a valid argument to attribute
'overflow_behavior'}}
+typedef int __attribute__((overflow_behavior("not_real"))) bad_arg_spec_str;
// expected-error {{'not_real' is not a valid argument to attribute
'overflow_behavior'}}
+typedef char* __attribute__((overflow_behavior("wrap"))) bad_type; //
expected-error {{'overflow_behavior' attribute cannot be applied to non-integer
type 'char *'}}
+
+typedef int __attribute__((overflow_behavior(wrap))) ok_wrap; // OK
+typedef long __attribute__((overflow_behavior(trap))) ok_nowrap; // OK
+typedef unsigned long __attribute__((overflow_behavior("wrap"))) str_ok_wrap;
// OK
+typedef char __attribute__((overflow_behavior("trap"))) str_ok_nowrap; // OK
+
+#define __wrap __attribute__((overflow_behavior(wrap)))
+#define __trap __attribute__((overflow_behavior(trap)))
+
+struct struct_not_allowed {
+ int i;
+} __attribute__((overflow_behavior(wrap))); // expected-warning
{{'overflow_behavior' attribute only applies to variables, typedefs, and
non-static data members}}
----------------
JustinStitt wrote:
The diagnostic messaging is just the default attr diag shipped when using
`Field` in the Subject list. I've modified the diag and added tests for static
vs non-static in
[3cf14e1](https://github.com/llvm/llvm-project/pull/148914/commits/3cf14e12f63ca9b8cffcf02f63df1d84144756e4).
https://github.com/llvm/llvm-project/pull/148914
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits