brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.6 KiB · 2ba5ca3 Raw
107 lines · c
1// RUN: %clang_cc1 %s -ast-print -verify > %t.c2// RUN: FileCheck %s --input-file %t.c3//4// RUN: echo >> %t.c "// expected""-warning@* {{use of GNU old-style field designator extension}}"5// RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes' is deprecated}}"6// RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes' has been explicitly marked deprecated here}}"7// RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes2' is deprecated}}"8// RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes2' has been explicitly marked deprecated here}}"9// RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes3' is deprecated}}"10// RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes3' has been explicitly marked deprecated here}}"11// RUN: %clang_cc1 -fsyntax-only %t.c -verify12 13typedef void func_typedef(void);14func_typedef xxx;15 16typedef void func_t(int x);17func_t a;18 19struct blah {20  struct {21    struct {22      int b;23    };24  };25};26 27// This used to crash clang.28struct {29}(s1);30 31int foo(const struct blah *b) {32  // CHECK: return b->b;33  return b->b;34}35 36int arr(int a[static 3]) {37  // CHECK: int a[static 3]38  return a[2];39}40 41int rarr(int a[restrict static 3]) {42  // CHECK: int a[restrict static 3]43  return a[2];44}45 46int varr(int n, int a[static n]) {47  // CHECK: int a[static n]48  return a[2];49}50 51int rvarr(int n, int a[restrict static n]) {52  // CHECK: int a[restrict static n]53  return a[2];54}55 56// CHECK: typedef struct {57typedef struct {58  int f;59} T __attribute__ ((__aligned__));60 61// CHECK: struct __attribute__((visibility("default"))) S;62struct __attribute__((visibility("default"))) S;63 64struct pair_t {65  int a;66  int b;67};68 69// CHECK: struct pair_t p = {a: 3, .b = 4};70struct pair_t p = {a: 3, .b = 4}; // expected-warning {{use of GNU old-style field designator extension}}71 72void initializers(void) {73  // CHECK: int *x = ((void *)0), *y = ((void *)0);74  int *x = ((void *)0), *y = ((void *)0);75  struct Z{};76  struct {77    struct Z z;78  // CHECK: } z = {(struct Z){}};79  } z = {(struct Z){}};80}81 82// CHECK-LABEL: enum __attribute__((deprecated(""))) EnumWithAttributes {83enum EnumWithAttributes { // expected-warning {{'EnumWithAttributes' is deprecated}}84  // CHECK-NEXT: EnumWithAttributesFoo __attribute__((deprecated(""))),85  EnumWithAttributesFoo __attribute__((deprecated)),86  // CHECK-NEXT: EnumWithAttributesBar __attribute__((unavailable(""))) = 5087  EnumWithAttributesBar __attribute__((unavailable)) = 5088  // CHECK-NEXT: } *EnumWithAttributesPtr;89} __attribute__((deprecated)) *EnumWithAttributesPtr; // expected-note {{'EnumWithAttributes' has been explicitly marked deprecated here}}90 91// CHECK-LABEL: enum __attribute__((deprecated(""))) EnumWithAttributes2 *EnumWithAttributes2Ptr;92// expected-warning@+2 {{'EnumWithAttributes2' is deprecated}}93// expected-note@+1 {{'EnumWithAttributes2' has been explicitly marked deprecated here}}94enum __attribute__((deprecated)) EnumWithAttributes2 *EnumWithAttributes2Ptr;95 96// CHECK-LABEL: EnumWithAttributes3Fn97void EnumWithAttributes3Fn(void) {98  // CHECK-NEXT: enum __attribute__((deprecated(""))) EnumWithAttributes3 *EnumWithAttributes3Ptr;99  // expected-warning@+2 {{'EnumWithAttributes3' is deprecated}}100  // expected-note@+1 {{'EnumWithAttributes3' has been explicitly marked deprecated here}}101  enum __attribute__((deprecated)) EnumWithAttributes3 *EnumWithAttributes3Ptr;102  // Printing must not put the attribute after the tag where it would apply to103  // the variable instead of the type, and then our deprecation warning would104  // move to this use of the variable.105  void *p = EnumWithAttributes3Ptr;106}107