brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · bab52b4 Raw
42 lines · c
1// RUN: %clang_cc1 -fsyntax-only -Wignored-attributes -verify -std=c23 %s2// RUN: %clang_cc1 -fsyntax-only -Wignored-attributes -verify -x c++ %s3// RUN: %clang_cc1 -fsyntax-only -ast-dump %s | FileCheck %s4 5inline int frob(int x) { return x; }6 7[[deprecated]] int frob(int); // expected-note 2 {{'frob' has been explicitly marked deprecated here}}8 9void use1() {10  // Using this should give a deprecation warning, but not a nodiscard warning.	11  frob(0); // expected-warning {{'frob' is deprecated}}12}13 14[[nodiscard]] int frob(int);15 16void use2() {17  // This should give both warnings.18  frob(0); // expected-warning {{'frob' is deprecated}} \19              expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}20}21 22[[maybe_unused]] int frob(int);23 24// Currently, this is only allowed for the standard spelling of the attributes.25void blob() {}                           // expected-note {{previous definition is here}}26__attribute__((deprecated)) void blob(); // expected-warning {{attribute declaration must precede definition}}27 28// CHECK: FunctionDecl {{.*}} frob29 30// CHECK: FunctionDecl {{.*}} prev {{.*}} frob31// CHECK:  DeprecatedAttr32 33// CHECK: FunctionDecl {{.*}} prev {{.*}} frob34// CHECK:  DeprecatedAttr35// CHECK:  WarnUnusedResultAttr36 37// CHECK: FunctionDecl {{.*}} prev {{.*}} frob38// CHECK:  DeprecatedAttr39// CHECK:  WarnUnusedResultAttr40// CHECK:  UnusedAttr41 42