Joel E. Denny | 7509a2f | 2018-05-14 19:36:45 +0000 | [diff] [blame^] | 1 | // Check struct: |
| 2 | // |
| 3 | // First check compiling and printing of this file. |
| 4 | // |
| 5 | // RUN: %clang -Xclang -verify -S -emit-llvm -DKW=struct -DBASES= -o - %s \ |
| 6 | // RUN: | FileCheck --check-prefixes=CHECK,LLVM %s |
| 7 | // |
| 8 | // RUN: %clang_cc1 -verify -ast-print -DKW=struct -DBASES= %s > %t.c |
| 9 | // RUN: FileCheck --check-prefixes=CHECK,PRINT -DKW=struct -DBASES= %s \ |
| 10 | // RUN: --input-file %t.c |
| 11 | // |
| 12 | // Now check compiling and printing of the printed file. |
| 13 | // |
| 14 | // RUN: echo "// expected""-warning@* 10 {{'T' is deprecated}}" >> %t.c |
| 15 | // RUN: echo "// expected""-note@* 10 {{'T' has been explicitly marked deprecated here}}" >> %t.c |
| 16 | // |
| 17 | // RUN: %clang -Xclang -verify -S -emit-llvm -o - %t.c \ |
| 18 | // RUN: | FileCheck --check-prefixes=CHECK,LLVM %s |
| 19 | // |
| 20 | // RUN: %clang_cc1 -verify -ast-print %t.c \ |
| 21 | // RUN: | FileCheck --check-prefixes=CHECK,PRINT -DKW=struct -DBASES= %s |
| 22 | |
| 23 | // Repeat for union: |
| 24 | // |
| 25 | // First check compiling and printing of this file. |
| 26 | // |
| 27 | // RUN: %clang -Xclang -verify -S -emit-llvm -DKW=union -DBASES= -o - %s \ |
| 28 | // RUN: | FileCheck --check-prefixes=CHECK,LLVM %s |
| 29 | // |
| 30 | // RUN: %clang_cc1 -verify -ast-print -DKW=union -DBASES= %s > %t.c |
| 31 | // RUN: FileCheck --check-prefixes=CHECK,PRINT -DKW=union -DBASES= %s \ |
| 32 | // RUN: --input-file %t.c |
| 33 | // |
| 34 | // Now check compiling and printing of the printed file. |
| 35 | // |
| 36 | // RUN: echo "// expected""-warning@* 10 {{'T' is deprecated}}" >> %t.c |
| 37 | // RUN: echo "// expected""-note@* 10 {{'T' has been explicitly marked deprecated here}}" >> %t.c |
| 38 | // |
| 39 | // RUN: %clang -Xclang -verify -S -emit-llvm -o - %t.c \ |
| 40 | // RUN: | FileCheck --check-prefixes=CHECK,LLVM %s |
| 41 | // |
| 42 | // RUN: %clang_cc1 -verify -ast-print %t.c \ |
| 43 | // RUN: | FileCheck --check-prefixes=CHECK,PRINT -DKW=union -DBASES= %s |
| 44 | |
| 45 | // Repeat for C++ (BASES helps ensure we're printing as C++ not as C): |
| 46 | // |
| 47 | // First check compiling and printing of this file. |
| 48 | // |
| 49 | // RUN: %clang -Xclang -verify -S -emit-llvm -DKW=struct -DBASES=' : B' -o - \ |
| 50 | // RUN: -xc++ %s \ |
| 51 | // RUN: | FileCheck --check-prefixes=CHECK,LLVM %s |
| 52 | // |
| 53 | // RUN: %clang_cc1 -verify -ast-print -DKW=struct -DBASES=' : B' -xc++ %s \ |
| 54 | // RUN: > %t.cpp |
| 55 | // RUN: FileCheck --check-prefixes=CHECK,PRINT,CXX -DKW=struct \ |
| 56 | // RUN: -DBASES=' : B' %s --input-file %t.cpp |
| 57 | // |
| 58 | // Now check compiling and printing of the printed file. |
| 59 | // |
| 60 | // RUN: echo "// expected""-warning@* 10 {{'T' is deprecated}}" >> %t.cpp |
| 61 | // RUN: echo "// expected""-note@* 10 {{'T' has been explicitly marked deprecated here}}" >> %t.cpp |
| 62 | // |
| 63 | // RUN: %clang -Xclang -verify -S -emit-llvm -o - %t.cpp \ |
| 64 | // RUN: | FileCheck --check-prefixes=CHECK,LLVM %s |
| 65 | // |
| 66 | // RUN: %clang_cc1 -verify -ast-print %t.cpp \ |
| 67 | // RUN: | FileCheck --check-prefixes=CHECK,PRINT,CXX -DKW=struct \ |
| 68 | // RUN: -DBASES=' : B' %s |
| 69 | |
| 70 | // END. |
| 71 | |
| 72 | #ifndef KW |
| 73 | # error KW undefined |
| 74 | # define KW struct // help syntax checkers |
| 75 | #endif |
| 76 | |
| 77 | #ifndef BASES |
| 78 | # error BASES undefined |
| 79 | # define BASES // help syntax checkers |
| 80 | #endif |
| 81 | |
| 82 | struct B {}; |
| 83 | |
| 84 | // CHECK-LABEL: defFirst |
| 85 | void defFirst() { |
| 86 | // PRINT-NEXT: [[KW]] |
| 87 | // PRINT-DAG: __attribute__((aligned(16))) |
| 88 | // PRINT-DAG: __attribute__((deprecated(""))) |
| 89 | // PRINT-NOT: __attribute__ |
| 90 | // PRINT-SAME: T[[BASES]] { |
| 91 | // PRINT-NEXT: int i; |
| 92 | // PRINT-NEXT: } *p0; |
| 93 | // expected-warning@+2 {{'T' is deprecated}} |
| 94 | // expected-note@+1 2 {{'T' has been explicitly marked deprecated here}} |
| 95 | KW __attribute__((aligned(16))) __attribute__((deprecated(""))) T BASES { |
| 96 | int i; |
| 97 | } *p0; |
| 98 | |
| 99 | // PRINT-NEXT: [[KW]] T *p1; |
| 100 | KW T *p1; // expected-warning {{'T' is deprecated}} |
| 101 | |
| 102 | // LLVM: store i64 16 |
| 103 | long s0 = sizeof *p0; |
| 104 | // LLVM-NEXT: store i64 16 |
| 105 | long s1 = sizeof *p1; |
| 106 | } |
| 107 | |
| 108 | // CHECK-LABEL: defLast |
| 109 | void defLast() { |
| 110 | // PRINT-NEXT: [[KW]] __attribute__((aligned(16))) T *p0; |
| 111 | KW __attribute__((aligned(16))) T *p0; |
| 112 | |
| 113 | // PRINT-NEXT: [[KW]] __attribute__((deprecated(""))) T[[BASES]] { |
| 114 | // PRINT-NEXT: int i; |
| 115 | // PRINT-NEXT: } *p1; |
| 116 | // expected-warning@+2 {{'T' is deprecated}} |
| 117 | // expected-note@+1 {{'T' has been explicitly marked deprecated here}} |
| 118 | KW __attribute__((deprecated(""))) T BASES { int i; } *p1; |
| 119 | |
| 120 | // LLVM: store i64 16 |
| 121 | long s0 = sizeof *p0; |
| 122 | // LLVM-NEXT: store i64 16 |
| 123 | long s1 = sizeof *p1; |
| 124 | } |
| 125 | |
| 126 | // CHECK-LABEL: defMiddle |
| 127 | void defMiddle() { |
| 128 | // PRINT-NEXT: [[KW]] __attribute__((deprecated(""))) T *p0; |
| 129 | // expected-warning@+2 {{'T' is deprecated}} |
| 130 | // expected-note@+1 3 {{'T' has been explicitly marked deprecated here}} |
| 131 | KW __attribute__((deprecated(""))) T *p0; |
| 132 | |
| 133 | // PRINT-NEXT: [[KW]] __attribute__((aligned(16))) T[[BASES]] { |
| 134 | // PRINT-NEXT: int i; |
| 135 | // PRINT-NEXT: } *p1; |
| 136 | KW __attribute__((aligned(16))) T BASES { int i; } *p1; // expected-warning {{'T' is deprecated}} |
| 137 | |
| 138 | // PRINT-NEXT: [[KW]] T *p2; |
| 139 | KW T *p2; // expected-warning {{'T' is deprecated}} |
| 140 | |
| 141 | // LLVM: store i64 16 |
| 142 | long s0 = sizeof *p0; |
| 143 | // LLVM-NEXT: store i64 16 |
| 144 | long s1 = sizeof *p1; |
| 145 | // LLVM-NEXT: store i64 16 |
| 146 | long s2 = sizeof *p2; |
| 147 | } |
| 148 | |
| 149 | // CHECK-LABEL: defSelfRef |
| 150 | void defSelfRef() { |
| 151 | // PRINT-NEXT: [[KW]] __attribute__((deprecated(""))) T *p0; |
| 152 | // expected-warning@+2 {{'T' is deprecated}} |
| 153 | // expected-note@+1 2 {{'T' has been explicitly marked deprecated here}} |
| 154 | KW __attribute__((deprecated(""))) T *p0; |
| 155 | |
| 156 | // PRINT-NEXT: [[KW]] __attribute__((aligned(16))) T[[BASES]] { |
| 157 | // PRINT-NEXT: int i; |
| 158 | // PRINT-NEXT: [[KW]] T *p2; |
| 159 | // PRINT-NEXT: } *p1; |
| 160 | KW __attribute__((aligned(16))) T BASES { // expected-warning {{'T' is deprecated}} |
| 161 | int i; |
| 162 | KW T *p2; |
| 163 | } *p1; |
| 164 | |
| 165 | // LLVM: store i64 16 |
| 166 | long s0 = sizeof *p0; |
| 167 | // LLVM-NEXT: store i64 16 |
| 168 | long s1 = sizeof *p1; |
| 169 | // LLVM-NEXT: store i64 16 |
| 170 | long s2 = sizeof *p0->p2; |
| 171 | // LLVM-NEXT: store i64 16 |
| 172 | long s3 = sizeof *p1->p2; |
| 173 | // LLVM-NEXT: store i64 16 |
| 174 | long s4 = sizeof *p1->p2->p2; |
| 175 | } |
| 176 | |
| 177 | // CHECK-LABEL: declsOnly |
| 178 | void declsOnly() { |
| 179 | // PRINT-NEXT: [[KW]] T *p0; |
| 180 | KW T *p0; |
| 181 | |
| 182 | // PRINT-NEXT: [[KW]] __attribute__((may_alias)) T *p1; |
| 183 | KW __attribute__((may_alias)) T *p1; |
| 184 | |
| 185 | // PRINT-NEXT: [[KW]] T *p2; |
| 186 | KW T *p2; |
| 187 | |
| 188 | // PRINT-NEXT: [[KW]] __attribute__((deprecated(""))) T *p3; |
| 189 | // expected-warning@+2 {{'T' is deprecated}} |
| 190 | // expected-note@+1 2 {{'T' has been explicitly marked deprecated here}} |
| 191 | KW __attribute__((deprecated(""))) T *p3; |
| 192 | |
| 193 | // PRINT-NEXT: [[KW]] T *p4; |
| 194 | KW T *p4; // expected-warning {{'T' is deprecated}} |
| 195 | } |
| 196 | |
| 197 | // Make sure expanded printing of tag types is turned back off in other parts |
| 198 | // of a tag declaration. The base class list is checked above. |
| 199 | |
| 200 | // CHECK-LABEL: inMembers |
| 201 | void inMembers() { |
| 202 | // PRINT-NEXT: [[KW]] T1 { |
| 203 | // PRINT-NEXT: int i; |
| 204 | // PRINT-NEXT: }; |
| 205 | KW T1 { int i; }; |
| 206 | // PRINT-NEXT: [[KW]] T2 { |
| 207 | // PRINT-NEXT: [[KW]] T1 i; |
| 208 | // PRINT-NEXT: }; |
| 209 | KW T2 { KW T1 i; }; |
| 210 | } |
| 211 | |
| 212 | // CHECK-LABEL: inInit |
| 213 | void inInit() { |
| 214 | // PRINT-NEXT: [[KW]] T1 { |
| 215 | // PRINT-NEXT: int i; |
| 216 | // PRINT-NEXT: }; |
| 217 | KW T1 { int i; }; |
| 218 | // PRINT-NEXT: [[KW]] T2 { |
| 219 | // PRINT-NEXT: long i; |
| 220 | // PRINT-NEXT: } t2 = {sizeof([[KW]] T1)}; |
| 221 | KW T2 { long i; } t2 = {sizeof(KW T1)}; |
| 222 | } |
| 223 | |
| 224 | #ifdef __cplusplus |
| 225 | // CXX-LABEL: inMemberPtr |
| 226 | void inMemberPtr() { |
| 227 | // CXX-NEXT: [[KW]] T1 { |
| 228 | // CXX-NEXT: int i; |
| 229 | // CXX-NEXT: }; |
| 230 | KW T1 { int i; }; |
| 231 | // CXX-NEXT: [[KW]] T2 { |
| 232 | // CXX-NEXT: } T1::*p; |
| 233 | KW T2 {} T1::*p; |
| 234 | } |
| 235 | #endif |