brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.8 KiB · 26a5f02 Raw
129 lines · cpp
1// RUN: rm -rf %t2// RUN: split-file %s %t3 4// RUN: %clang_cc1 -std=c++2a -verify %t/M.cppm5// RUN: %clang_cc1 -std=c++2a -verify %t/NoGlobalFrag.cppm6// RUN: %clang_cc1 -std=c++2a -verify %t/NoModuleDecl.cppm7// RUN: %clang_cc1 -std=c++2a -verify %t/NoPrivateFrag.cppm8// RUN: %clang_cc1 -std=c++2a -verify %t/NoModuleDeclAndNoPrivateFrag.cppm9// RUN: %clang_cc1 -std=c++2a -verify %t/NoGlobalFragAndNoPrivateFrag.cppm10// RUN: %clang_cc1 -std=c++2a -verify %t/NoGlobalFragAndNoModuleDecl.cppm11// RUN: %clang_cc1 -std=c++2a -verify %t/NoGlobalFragAndNoModuleDeclAndNoPrivateFrag.cppm12// RUN: %clang_cc1 -std=c++2a -verify %t/ExportFrags.cppm13 14//--- M.cppm15module;16extern int a; // #a117export module Foo;18 19int a; // expected-error {{declaration of 'a' in module Foo follows declaration in the global module}}20       // expected-note@#a1 {{previous decl}}21extern int b;22 23module; // expected-error {{'module;' introducing a global module fragment can appear only at the start of the translation unit}}24module :private; // #priv-frag25int b; // ok26module :private; // expected-error {{private module fragment redefined}}27                 // expected-note@#priv-frag {{previous definition is here}}28 29//--- NoGlobalFrag.cppm30 31extern int a; // #a132export module Foo; // expected-error {{module declaration must occur at the start of the translation unit}}33                   // expected-note@-2 {{add 'module;' to the start of the file to introduce a global module fragment}}34 35// expected-error@#a2 {{declaration of 'a' in module Foo follows declaration in the global module}}36// expected-note@#a1 {{previous decl}}37 38int a; // #a239extern int b;40module; // expected-error {{'module;' introducing a global module fragment can appear only at the start of the translation unit}}41module :private; // #priv-frag42int b; // ok43module :private; // expected-error {{private module fragment redefined}}44// expected-note@#priv-frag {{previous definition is here}}45 46//--- NoModuleDecl.cppm47module; // expected-error {{missing 'module' declaration at end of global module fragment introduced here}}48extern int a; // #a149int a; // #a250extern int b;51module; // expected-error {{'module;' introducing a global module fragment can appear only at the start of the translation unit}}52module :private; // expected-error {{private module fragment declaration with no preceding module declaration}}53int b; // ok54 55//--- NoPrivateFrag.cppm56module;57extern int a; // #a158export module Foo;59 60// expected-error@#a2 {{declaration of 'a' in module Foo follows declaration in the global module}}61// expected-note@#a1 {{previous decl}}62int a; // #a263extern int b;64 65module; // expected-error {{'module;' introducing a global module fragment can appear only at the start of the translation unit}}66int b; // ok67 68 69//--- NoModuleDeclAndNoPrivateFrag.cppm70module; // expected-error {{missing 'module' declaration at end of global module fragment introduced here}}71extern int a; // #a172int a; // #a273extern int b;74 75module; // expected-error {{'module;' introducing a global module fragment can appear only at the start of the translation unit}}76 77int b; // ok78 79//--- NoGlobalFragAndNoPrivateFrag.cppm80extern int a; // #a181export module Foo; // expected-error {{module declaration must occur at the start of the translation unit}}82// expected-note@1 {{add 'module;' to the start of the file to introduce a global module fragment}}83 84// expected-error@#a2 {{declaration of 'a' in module Foo follows declaration in the global module}}85// expected-note@#a1 {{previous decl}}86 87int a; // #a288extern int b;89 90module; // expected-error {{'module;' introducing a global module fragment can appear only at the start of the translation unit}}91 92int b; // ok93 94//--- NoGlobalFragAndNoModuleDecl.cppm95extern int a; // #a196int a; // #a297extern int b;98module; // expected-error {{'module;' introducing a global module fragment can appear only at the start of the translation unit}}99module :private; // #priv-frag100// expected-error@-1 {{private module fragment declaration with no preceding module declaration}}101int b; // ok102 103 104//--- NoGlobalFragAndNoModuleDeclAndNoPrivateFrag.cppm105extern int a; // #a1106int a; // #a2107extern int b;108 109module; // expected-error {{'module;' introducing a global module fragment can appear only at the start of the translation unit}}110int b; // ok111 112//--- ExportFrags.cppm113export module; // expected-error {{global module fragment cannot be exported}}114extern int a; // #a1115export module Foo;116// expected-error@#a2 {{declaration of 'a' in module Foo follows declaration in the global module}}117// expected-note@#a1 {{previous decl}}118 119int a; // #a2120extern int b;121 122module; // expected-error {{'module;' introducing a global module fragment can appear only at the start of the translation unit}}123 124module :private; // #priv-frag125 126int b; // ok127module :private; // expected-error {{private module fragment redefined}}128                 // expected-note@#priv-frag {{previous definition is here}}129