llvm-project/clang/test/Sema/pragma-attribute-namespace.c
Aaron Ballman 8c5edb59cf Use functions with prototypes when appropriate; NFC
A significant number of our tests in C accidentally use functions
without prototypes. This patch converts the function signatures to have
a prototype for the situations where the test is not specific to K&R C
declarations. e.g.,

  void func();

becomes

  void func(void);

This is the second batch of tests being updated (there are a significant
number of other tests left to be updated).
2022-02-04 15:20:36 -05:00

42 lines
2.2 KiB
C

// RUN: %clang_cc1 -fsyntax-only -verify %s
#if !__has_extension(pragma_clang_attribute_namespaces)
#error
#endif
#pragma clang attribute MyNamespace.push (__attribute__((annotate)), apply_to=function) // expected-error 2 {{'annotate' attribute}}
int some_func(void); // expected-note{{when applied to this declaration}}
#pragma clang attribute pop // expected-error{{'#pragma clang attribute pop' with no matching '#pragma clang attribute push'}}
#pragma clang attribute NotMyNamespace.pop // expected-error{{'#pragma clang attribute NotMyNamespace.pop' with no matching '#pragma clang attribute NotMyNamespace.push'}}
#pragma clang attribute MyOtherNamespace.push (__attribute__((annotate)), apply_to=function) // expected-error 2 {{'annotate' attribute}}
int some_other_func(void); // expected-note 2 {{when applied to this declaration}}
// Out of order!
#pragma clang attribute MyNamespace.pop
int some_other_other_func(void); // expected-note 1 {{when applied to this declaration}}
#pragma clang attribute MyOtherNamespace.pop
#pragma clang attribute Misc. () // expected-error{{namespace can only apply to 'push' or 'pop' directives}} expected-note {{omit the namespace to add attributes to the most-recently pushed attribute group}}
#pragma clang attribute Misc push // expected-error{{expected '.' after pragma attribute namespace 'Misc'}}
// Test how pushes with namespaces interact with pushes without namespaces.
#pragma clang attribute Merp.push (__attribute__((annotate)), apply_to=function) // expected-error{{'annotate' attribute}}
#pragma clang attribute push (__attribute__((annotate)), apply_to=function) // expected-warning {{unused attribute}}
#pragma clang attribute pop // expected-note{{ends here}}
int test(void); // expected-note{{when applied to this declaration}}
#pragma clang attribute Merp.pop
#pragma clang attribute push (__attribute__((annotate)), apply_to=function) // expected-warning {{unused attribute}}
#pragma clang attribute Merp.push (__attribute__((annotate)), apply_to=function) // expected-error{{'annotate' attribute}}
#pragma clang attribute pop // expected-note{{ends here}}
int test2(void); // expected-note{{when applied to this declaration}}
#pragma clang attribute Merp.pop