brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.3 KiB · a8cd523 Raw
143 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST12// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST23// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST34// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST45// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++14 -DTEST56// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++14 -DTEST67// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST78// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST89// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST910// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST10 -ffreestanding11// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s -DTEST1112// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s -DTEST1213// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s -DTEST1314// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s -DTEST1415// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm-only -verify -pedantic %s -DTEST1516 17#if TEST118int main; // expected-error{{main cannot be declared as a variable in the global scope}}19 20#elif TEST221// expected-no-diagnostics22int f () {23  int main;24  return main;25}26 27#elif TEST328// expected-no-diagnostics29void x(int main) {};30int y(int main);31 32#elif TEST433// expected-no-diagnostics34class A {35  static int main;36};37 38#elif TEST539// expected-no-diagnostics40template<class T> constexpr T main;41 42#elif TEST643extern template<class T> constexpr T main; //expected-error{{expected unqualified-id}}44 45#elif TEST746// expected-no-diagnostics47namespace foo {48  int main;49}50 51#elif TEST852void z(void)53{54  extern int main;  // expected-error{{main cannot be declared as a variable in the global scope}}}55}56 57#elif TEST958// expected-no-diagnostics59int q(void)60{61  static int main;62  return main;63}64 65#elif TEST1066// expected-no-diagnostics67int main;68 69#elif TEST1170extern "C" {71  namespace Y {72    int main; // expected-error {{main cannot be declared as a variable with C language linkage}}}73  }74}75namespace ns {76  extern "C" int main; // expected-error {{main cannot be declared as a variable with C language linkage}}77}78 79#elif TEST1280extern "C" struct A { int main(); }; // ok81 82namespace c {83  extern "C" void main(); // expected-error {{'main' must return 'int'}} \84                          // expected-warning {{'main' should not be 'extern "C"'}}85}86 87extern "C" {88  namespace Z {89    void main(); // expected-error {{'main' must return 'int'}} \90                 // expected-warning {{'main' should not be 'extern "C"'}}91  }92}93 94namespace ns {95  extern "C" struct A {96    int main; // ok97  };98 99  extern "C" struct B {100    int main(); // ok101  };102}103 104#elif TEST13105// expected-no-diagnostics106extern "C++" {107  int main();108}109 110extern "C++" int main();111 112namespace ns1 {113  extern "C++" int main(); // ok114  extern "C" {115    extern "C++" {116      int main(void *); // ok117    }118  }119}120 121namespace ns2 {122  extern "C++" void main() {} // ok123}124 125#elif TEST14126extern "C" {127  int main(); // expected-warning {{'main' should not be 'extern "C"'}}128}129 130extern "C" int main(); // expected-warning {{'main' should not be 'extern "C"'}}131 132#elif TEST15133extern "C" __attribute__((visibility("default"))) __attribute__((weak))134int main(); // expected-warning {{'main' should not be 'extern "C"'}}135 136unsigned long g() {137  return reinterpret_cast<unsigned long>(&main); // expected-warning {{referring to 'main' within an expression is a Clang extension}}138}139 140#else141#error Unknown Test142#endif143