// RUN: clang -fsyntax-only -verify %s

// --- decl-specifier storage-class-specifier extern ---

//objects
extern char foo;        
struct DS;
extern struct DS ds;      
extern struct S s;      
extern union U u;      
// extern class C c; // FIXME:  support for class keyword       

//functions
extern char bar(int);

// --- linkage-specification --- 

// syntax: extern string-literal declaration
extern "C" int g();
extern "C++" int h();
extern "FORTRAN" int F(); // expected-error {{unknown linkage language}}
extern "Fortran" int F(); // expected-error {{unknown linkage language}}

// syntax: extern string-literal { declaration-seqopt }
extern "C" {
  int cg();
  int ch();
}
extern "C++" {
  int cxxg();
  int cxxh();
}

// extern {       // should be "C++" as default language I think, 
                  // but g++ emit: cxx-extern.cpp:33: error: expected unqualified-id before ‘{’ token
   
//   int cxxg();  // redeclare cxxg(), Ok
//   int cxxh();  // redeclare cxxh(), Ok
// }

extern "FORTRAN" {  // expected-error {{unknown linkage language}}
  int FG();
  int FH();
} 

extern "Ada" {  // expected-error {{unknown linkage language}}
  int AG();
  int AH();
} 

// --- nested linkage-specifier

extern "C++" {
  int cpp_ggg();            // C++ linkage

  extern "C" {
    void c_ggg();         // C linkage

    extern "Ada" {  // expected-error {{unknown linkage language}}
      void ada_ggg();         // Ada linkage
      extern int cpp_ggg2();  // C++ linkage ??
      extern int c_ggg2();    // C linkage ??
    }
  }
}



// --- explicit-instantiation ---
// extern template declaration
// FIXME:  need tests if C++ explicit-instantiation dark corners are ever explored
