brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.8 KiB · fa12a15 Raw
76 lines · c
1// RUN: %clang_cc1 -isystem %S/Inputs -fsyntax-only -verify -Wreserved-identifier -Wno-visibility %s2 3#include <reserved-identifier.h>4 5__I_AM_A_SYSTEM_MACRO() // no-warning6 7void test_system_macro_expansion(void) {8  SOME_SYSTEM_MACRO(); // no-warning9}10 11#define __oof foo__ // expected-warning {{macro name is a reserved identifier}}12 13int foo__bar(void) { return 0; }    // no-warning14static int _bar(void) { return 0; } // expected-warning {{identifier '_bar' is reserved because it starts with '_' at global scope}}15static int _Bar(void) { return 0; } // expected-warning {{identifier '_Bar' is reserved because it starts with '_' followed by a capital letter}}16int _foo(void) { return 0; }        // expected-warning {{identifier '_foo' is reserved because it starts with '_' at global scope}}17 18// This one is explicitly skipped by -Wreserved-identifier19void *_; // no-warning20 21void foo(unsigned int _Reserved) { // expected-warning {{identifier '_Reserved' is reserved because it starts with '_' followed by a capital letter}}22  unsigned int __1 =               // expected-warning {{identifier '__1' is reserved because it starts with '__'}}23      _Reserved;                   // no-warning24  goto __reserved;                 // expected-warning {{identifier '__reserved' is reserved because it starts with '__'}}25__reserved: // expected-warning {{identifier '__reserved' is reserved because it starts with '__'}}26            ;27  goto _not_reserved;28_not_reserved: ;29}30 31void foot(unsigned int _not_reserved) {} // no-warning32 33enum __menu { // expected-warning {{identifier '__menu' is reserved because it starts with '__'}}34  __some,     // expected-warning {{identifier '__some' is reserved because it starts with '__'}}35  _Other,     // expected-warning {{identifier '_Other' is reserved because it starts with '_' followed by a capital letter}}36  _other      // expected-warning {{identifier '_other' is reserved because it starts with '_' at global scope}}37};38 39struct __babar { // expected-warning {{identifier '__babar' is reserved because it starts with '__'}}40};41 42struct _Zebulon;   // expected-warning {{identifier '_Zebulon' is reserved because it starts with '_' followed by a capital letter}}43struct _Zebulon2 { // expected-warning {{identifier '_Zebulon2' is reserved because it starts with '_' followed by a capital letter}}44} * p;45struct _Zebulon3 *pp; // expected-warning {{identifier '_Zebulon3' is reserved because it starts with '_' followed by a capital letter}}46 47typedef struct {48  int _Field; // expected-warning {{identifier '_Field' is reserved because it starts with '_' followed by a capital letter}}49  int _field; // no-warning50} _Typedef;   // expected-warning {{identifier '_Typedef' is reserved because it starts with '_' followed by a capital letter}}51 52int foobar(void) {53  return foo__bar(); // no-warning54}55 56struct _reserved { // expected-warning {{identifier '_reserved' is reserved because it starts with '_' at global scope}}57  int a;58} cunf(void) {59  return (struct _reserved){1};60}61 62// FIXME: According to clang declaration context layering, _preserved belongs to63// the translation unit, so we emit a warning. It's unclear that's what the64// standard mandate, but it's such a corner case we can live with it.65void func(struct _preserved { int a; } r) {} // expected-warning {{identifier '_preserved' is reserved because it starts with '_' at global scope}}66 67extern char *_strdup(const char *); // expected-warning {{identifier '_strdup' is reserved because it starts with '_' at global scope}}68 69// Don't warn on redeclaration70extern char *_strdup(const char *); // no-warning71 72void ok(void) {73  void _ko(void);           // expected-warning {{identifier '_ko' is reserved because it starts with '_' at global scope}}74  extern int _ko_again; // expected-warning {{identifier '_ko_again' is reserved because it starts with '_' at global scope}}75}76