brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.3 KiB · c73505d Raw
119 lines · c
1// RUN: %clang_cc1 -fsyntax-only -verify %s -pedantic -std=c99 -Wno-strict-prototypes2 3int __attribute__(()) x;4 5__inline void __attribute__((__always_inline__, __nodebug__))6foo(void) {7}8 9 10__attribute__(()) y;   // expected-error {{type specifier missing, defaults to 'int'}}11 12// PR279613int (__attribute__(()) *z)(long y);14 15 16void f1(__attribute__(()) int x);17 18int f2(y, __attribute__(()) x);     // expected-error {{expected identifier}}19 20// This is parsed as a normal argument list (with two args that are implicit21// int) because the __attribute__ is a declspec.22void f3(__attribute__(()) x,  // expected-error {{type specifier missing, defaults to 'int'}}23        y);               // expected-error {{type specifier missing, defaults to 'int'}}24 25void f4(__attribute__(()));   // expected-error {{expected parameter declarator}}26 27 28// This is ok, the __attribute__ applies to the pointer.29int baz(int (__attribute__(()) *x)(long y));30 31void g1(void (*f1)(__attribute__(()) int x));32void g2(int (*f2)(y, __attribute__(()) x));    // expected-error {{expected identifier}}33void g3(void (*f3)(__attribute__(()) x, int y));  // expected-error {{type specifier missing, defaults to 'int'}}34void g4(void (*f4)(__attribute__(())));  // expected-error {{expected parameter declarator}}35 36 37void (*h1)(void (*f1)(__attribute__(()) int x));38void (*h2)(int (*f2)(y, __attribute__(()) x));    // expected-error {{expected identifier}}39 40void (*h3)(void (*f3)(__attribute__(()) x));   // expected-error {{type specifier missing, defaults to 'int'}}41void (*h4)(void (*f4)(__attribute__(())));  // expected-error {{expected parameter declarator}}42 43int foo42(void) {44  int x, __attribute__((unused)) y, z;45  return 0;46}47 48void __attribute__((noreturn)) d0(void), __attribute__((noreturn)) d1(void);49 50void d2(void) __attribute__((noreturn)), d3(void) __attribute__((noreturn));51 52 53// PR628754void __attribute__((returns_twice)) returns_twice_test(void);55 56int aligned(int);57int __attribute__((vec_type_hint(char, aligned(16) )) missing_rparen_1; // expected-error 2{{expected ')'}} expected-note {{to match}} expected-warning {{does not declare anything}}58int __attribute__((mode(x aligned(16) )) missing_rparen_2; // expected-error 2{{expected ')'}}59int __attribute__((format(printf, 0 aligned(16) )) missing_rparen_3; // expected-error 2{{expected ')'}}60 61 62 63int testFundef1(int *a) __attribute__((nonnull(1))) { // \64    // expected-warning {{GCC does not allow 'nonnull' attribute in this position on a function definition}}65  return *a;66}67 68// noreturn is lifted to type qualifier69void testFundef2(void) __attribute__((noreturn)) { // \70    // expected-warning {{GCC does not allow 'noreturn' attribute in this position on a function definition}}71  testFundef2();72}73 74int testFundef3(int *a) __attribute__((nonnull(1), // \75    // expected-warning {{GCC does not allow 'nonnull' attribute in this position on a function definition}}76                                     pure)) { // \77    // expected-warning {{GCC does not allow 'pure' attribute in this position on a function definition}}78  return *a;79}80 81int testFundef4(int *a) __attribute__((nonnull(1))) // \82    // expected-warning {{GCC does not allow 'nonnull' attribute in this position on a function definition}}83                      __attribute((pure)) { // \84    // expected-warning {{GCC does not allow 'pure' attribute in this position on a function definition}}85  return *a;86}87 88// GCC allows these89void testFundef5(void) __attribute__(()) { }90 91__attribute__((pure)) int testFundef6(int a) { return a; }92 93void deprecatedTestFun(void) __attribute__((deprecated()));94 95struct s {96  int a;97};98 99// This test ensure compatibility with parsing GNU-style attributes100// where the attribute is on a separate line from the elaborated type101// specifier.102struct s103__attribute__((used)) bar;104 105// Ensure that attributes must be separated by a comma (PR38352).106__attribute__((const const)) int PR38352(void); // expected-error {{expected ')'}}107// Also ensure that we accept spurious commas.108__attribute__((,,,const)) int PR38352_1(void);109__attribute__((const,,,)) int PR38352_2(void);110__attribute__((const,,,const)) int PR38352_3(void);111__attribute__((,,,const,,,const,,,)) int PR38352_4(void);112 113// Test that we allow attributes on free-standing decl-specifier-seqs.114// GCC appears to allow this.115__attribute__(()) struct t;116void f5() {117  __attribute__(()) struct t;118}119