| Joel E. Denny | 7bcc210 | 2018-05-14 18:41:44 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -verify -ast-print %s -xc -DDEF_BOOL_CBOOL \ |
| 2 | // RUN: | FileCheck %s --check-prefixes=BOOL-AS-CBOOL,CBOOL |
| 3 | // |
| 4 | // RUN: %clang_cc1 -verify -ast-print %s -xc -DDEF_BOOL_CBOOL -DDIAG \ |
| 5 | // RUN: | FileCheck %s --check-prefixes=BOOL-AS-CBOOL,CBOOL |
| 6 | // |
| 7 | // RUN: %clang_cc1 -verify -ast-print %s -xc -DDEF_BOOL_INT \ |
| 8 | // RUN: | FileCheck %s --check-prefixes=BOOL-AS-INT,CBOOL |
| 9 | // |
| 10 | // RUN: %clang_cc1 -verify -ast-print %s -xc -DDEF_BOOL_INT -DDIAG \ |
| 11 | // RUN: | FileCheck %s --check-prefixes=BOOL-AS-INT,CBOOL |
| 12 | // |
| 13 | // RUN: %clang_cc1 -verify -ast-print %s -xc++ \ |
| 14 | // RUN: | FileCheck %s --check-prefixes=BOOL-AS-BOOL |
| 15 | // |
| 16 | // RUN: %clang_cc1 -verify -ast-print %s -xc++ -DDIAG \ |
| 17 | // RUN: | FileCheck %s --check-prefixes=BOOL-AS-BOOL |
| 18 | |
| 19 | #if DEF_BOOL_CBOOL |
| 20 | # define bool _Bool |
| 21 | #elif DEF_BOOL_INT |
| 22 | # define bool int |
| 23 | #endif |
| 24 | |
| 25 | // BOOL-AS-CBOOL: _Bool i; |
| 26 | // BOOL-AS-INT: int i; |
| 27 | // BOOL-AS-BOOL: bool i; |
| 28 | bool i; |
| 29 | |
| 30 | #ifndef __cplusplus |
| 31 | // CBOOL: _Bool j; |
| 32 | _Bool j; |
| 33 | #endif |
| 34 | |
| 35 | // Induce a diagnostic (and verify we actually managed to do so), which used to |
| 36 | // permanently alter the -ast-print printing policy for _Bool. How bool is |
| 37 | // defined by the preprocessor is examined only once per compilation, when the |
| 38 | // diagnostic is emitted, and it used to affect the entirety of -ast-print, so |
| 39 | // test only one definition of bool per compilation. |
| 40 | #if DIAG |
| 41 | void fn() { 1; } // expected-warning {{expression result unused}} |
| 42 | #else |
| 43 | // expected-no-diagnostics |
| 44 | #endif |