Filipe Cabecinhas | 28f353c | 2015-01-29 23:56:43 +0000 | [diff] [blame] | 1 | // Check that we emit warnings/errors for different combinations of |
| 2 | // exceptions, rtti, and vptr sanitizer flags when targetting the PS4. |
| 3 | // No warnings/errors should be emitted for unknown, except if combining |
| 4 | // the vptr sanitizer with -fno-rtti |
| 5 | |
Filipe Cabecinhas | 3e707d9 | 2015-03-20 23:33:23 +0000 | [diff] [blame^] | 6 | // Special case: -fcxx-exceptions in C code should warn about unused arguments |
| 7 | // RUN: %clang -x c -### -c -fcxx-exceptions %s 2>&1 | FileCheck -check-prefix=CHECK-UNUSED %s |
| 8 | // CHECK-UNUSED: warning: argument unused during compilation: '-fcxx-exceptions' |
| 9 | |
Filipe Cabecinhas | ec5d0e6 | 2015-02-19 01:04:49 +0000 | [diff] [blame] | 10 | // RUN: %clang -### -c -fno-rtti -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-RTTI %s |
| 11 | // RUN: %clang -### -c -frtti -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-NO-RTTI %s |
| 12 | |
Filipe Cabecinhas | 28f353c | 2015-01-29 23:56:43 +0000 | [diff] [blame] | 13 | // -fsanitize=vptr |
Filipe Cabecinhas | ec5d0e6 | 2015-02-19 01:04:49 +0000 | [diff] [blame] | 14 | // Make sure we only error/warn once, when trying to enable vptr and |
| 15 | // undefined and have -fno-rtti |
| 16 | // RUN: %clang -### -c -fsanitize=undefined -fsanitize=vptr -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-SAN-ERROR -check-prefix=CHECK-OK %s |
| 17 | |
Filipe Cabecinhas | 28f353c | 2015-01-29 23:56:43 +0000 | [diff] [blame] | 18 | // RUN: %clang -### -c -target x86_64-scei-ps4 -fsanitize=vptr %s 2>&1 | FileCheck -check-prefix=CHECK-SAN-WARN %s |
| 19 | // RUN: %clang -### -c -target x86_64-scei-ps4 -fsanitize=vptr -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s |
| 20 | // RUN: %clang -### -c -target x86_64-scei-ps4 -fsanitize=vptr -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-SAN-ERROR %s |
Filipe Cabecinhas | 28f353c | 2015-01-29 23:56:43 +0000 | [diff] [blame] | 21 | // RUN: %clang -### -c -target x86_64-scei-ps4 -fsanitize=undefined -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s |
Filipe Cabecinhas | 28f353c | 2015-01-29 23:56:43 +0000 | [diff] [blame] | 22 | // RUN: %clang -### -c -target x86_64-unknown-unknown -fsanitize=vptr %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s |
| 23 | // RUN: %clang -### -c -target x86_64-unknown-unknown -fsanitize=vptr -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s |
| 24 | // RUN: %clang -### -c -target x86_64-unknown-unknown -fsanitize=vptr -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-SAN-ERROR %s |
| 25 | // RUN: %clang -### -c -target x86_64-unknown-unknown -fsanitize=undefined %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s |
| 26 | // RUN: %clang -### -c -target x86_64-unknown-unknown -fsanitize=undefined -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s |
Filipe Cabecinhas | 28f353c | 2015-01-29 23:56:43 +0000 | [diff] [blame] | 27 | |
| 28 | // Exceptions + no/default rtti |
Filipe Cabecinhas | 28f353c | 2015-01-29 23:56:43 +0000 | [diff] [blame] | 29 | // RUN: %clang -### -c -target x86_64-scei-ps4 -fcxx-exceptions -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-EXC-ERROR-CXX %s |
Filipe Cabecinhas | 28f353c | 2015-01-29 23:56:43 +0000 | [diff] [blame] | 30 | // RUN: %clang -### -c -target x86_64-scei-ps4 -fcxx-exceptions %s 2>&1 | FileCheck -check-prefix=CHECK-EXC-WARN %s |
Filipe Cabecinhas | 28f353c | 2015-01-29 23:56:43 +0000 | [diff] [blame] | 31 | // RUN: %clang -### -c -target x86_64-unknown-unknown -fcxx-exceptions -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s |
Filipe Cabecinhas | 28f353c | 2015-01-29 23:56:43 +0000 | [diff] [blame] | 32 | // RUN: %clang -### -c -target x86_64-unknown-unknown -fcxx-exceptions %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s |
Filipe Cabecinhas | f2a3aec | 2015-01-31 23:05:51 +0000 | [diff] [blame] | 33 | // In C++, -fexceptions implies -fcxx-exceptions |
| 34 | // RUN: %clang -x c++ -### -c -target x86_64-scei-ps4 -fexceptions -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-EXC-ERROR %s |
| 35 | // RUN: %clang -x c++ -### -c -target x86_64-scei-ps4 -fexceptions %s 2>&1 | FileCheck -check-prefix=CHECK-EXC-WARN %s |
| 36 | // RUN: %clang -x c++ -### -c -target x86_64-unknown-unknown -fexceptions -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s |
| 37 | // RUN: %clang -x c++ -### -c -target x86_64-unknown-unknown -fexceptions %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s |
Filipe Cabecinhas | 28f353c | 2015-01-29 23:56:43 +0000 | [diff] [blame] | 38 | |
| 39 | // -frtti + exceptions |
Filipe Cabecinhas | 28f353c | 2015-01-29 23:56:43 +0000 | [diff] [blame] | 40 | // RUN: %clang -### -c -target x86_64-scei-ps4 -fcxx-exceptions -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s |
Filipe Cabecinhas | 28f353c | 2015-01-29 23:56:43 +0000 | [diff] [blame] | 41 | // RUN: %clang -### -c -target x86_64-unknown-unknown -fcxx-exceptions -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s |
| 42 | |
| 43 | // -f{no-,}rtti/default |
| 44 | // RUN: %clang -### -c -target x86_64-scei-ps4 -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-RTTI %s |
| 45 | // RUN: %clang -### -c -target x86_64-scei-ps4 -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-NO-RTTI %s |
| 46 | // RUN: %clang -### -c -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=CHECK-NO-RTTI %s |
| 47 | // RUN: %clang -### -c -target x86_64-unknown-unknown -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-RTTI %s |
| 48 | // RUN: %clang -### -c -target x86_64-unknown-unknown -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-NO-RTTI %s |
| 49 | // RUN: %clang -### -c -target x86_64-unknown-unknown %s 2>&1 | FileCheck -check-prefix=CHECK-RTTI %s |
| 50 | |
| 51 | // CHECK-SAN-WARN: implicitly disabling vptr sanitizer because rtti wasn't enabled |
| 52 | // CHECK-SAN-ERROR: invalid argument '-fsanitize=vptr' not allowed with '-fno-rtti' |
| 53 | // CHECK-EXC-WARN: implicitly enabling rtti for exception handling |
Filipe Cabecinhas | f2a3aec | 2015-01-31 23:05:51 +0000 | [diff] [blame] | 54 | // CHECK-EXC-ERROR: invalid argument '-fno-rtti' not allowed with '-fexceptions' |
Filipe Cabecinhas | 28f353c | 2015-01-29 23:56:43 +0000 | [diff] [blame] | 55 | // CHECK-EXC-ERROR-CXX: invalid argument '-fno-rtti' not allowed with '-fcxx-exceptions' |
| 56 | // CHECK-RTTI-NOT: "-fno-rtti" |
| 57 | // CHECK-NO-RTTI-NOT: "-frtti" |
| 58 | |
| 59 | // CHECK-OK-NOT: {{warning:|error:}} |