]> granicus.if.org Git - clang/commitdiff
Type safety attributes: add tests for enumerations (users are actually doing
authorDmitri Gribenko <gribozavr@gmail.com>
Wed, 2 Jan 2013 21:12:03 +0000 (21:12 +0000)
committerDmitri Gribenko <gribozavr@gmail.com>
Wed, 2 Jan 2013 21:12:03 +0000 (21:12 +0000)
this, ensure we don't regress)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171412 91177308-0d34-0410-b5e6-96231b3b80d8

test/Sema/warn-type-safety-mpi-hdf5.c

index 8c50cb24bb60aefbe527f96ebec4aa571fe3cb9a..1a9c5b077297fc0b9837aeaa23065bd60d8e8dea 100644 (file)
@@ -201,10 +201,14 @@ MPI_Datatype my_s1_datatype __attribute__(( type_tag_for_datatype(mpi,struct S1)
 struct S2 { int a; int b; };
 MPI_Datatype my_s2_datatype __attribute__(( type_tag_for_datatype(mpi,struct S2) ));
 
+enum E1 { Foo };
+MPI_Datatype my_e1_datatype __attribute__(( type_tag_for_datatype(mpi,enum E1) ));
+
 void test_user_types(int *int_buf,
                      long *long_buf,
                      struct S1 *s1_buf,
-                     struct S2 *s2_buf)
+                     struct S2 *s2_buf,
+                     enum E1 *e1_buf)
 {
   MPI_Send(int_buf,  1, my_int_datatype); // no-warning
   MPI_Send(long_buf, 1, my_int_datatype); // expected-warning {{argument type 'long *' doesn't match specified 'mpi' type tag that requires 'int *'}}
@@ -214,6 +218,10 @@ void test_user_types(int *int_buf,
 
   MPI_Send(long_buf, 1, my_s1_datatype); // expected-warning {{argument type 'long *' doesn't match specified 'mpi' type tag that requires 'struct S1 *'}}
   MPI_Send(s1_buf, 1, MPI_INT); // expected-warning {{argument type 'struct S1 *' doesn't match specified 'mpi' type tag that requires 'int *'}}
+
+  MPI_Send(e1_buf, 1, my_e1_datatype); // no-warning
+  MPI_Send(e1_buf, 1, MPI_INT); // expected-warning {{argument type 'enum E1 *' doesn't match specified 'mpi' type tag that requires 'int *'}}
+  MPI_Send(int_buf, 1, my_e1_datatype); // expected-warning {{argument type 'int *' doesn't match specified 'mpi' type tag that requires 'enum E1 *'}}
 }
 
 MPI_Datatype my_unknown_datatype;