1 // RUN: %clang_cc1 -funknown-anytype -fsyntax-only -verify %s 2 3 namespace test0 { 4 extern __unknown_anytype test0; 5 extern __unknown_anytype test1(); 6 extern __unknown_anytype test2(int); 7 } 8 9 namespace test1 { 10 extern __unknown_anytype foo; test()11 int test() { 12 // TODO: it would be great if the 'cannot initialize' errors 13 // turned into something more interesting. It's just a matter of 14 // making sure that these locations check for placeholder types 15 // properly. 16 17 int x = foo; // expected-error {{'foo' has unknown type}} 18 int y = 0 + foo; // expected-error {{'foo' has unknown type}} 19 return foo; // expected-error {{'foo' has unknown type}} 20 } 21 } 22 23 namespace test2 { 24 extern __unknown_anytype foo(); test()25 void test() { 26 foo(); // expected-error {{'foo' has unknown return type}} 27 } 28 } 29 30 namespace test3 { 31 extern __unknown_anytype foo; test()32 void test() { 33 foo(); // expected-error {{call to unsupported expression with unknown type}} 34 ((void(void)) foo)(); // expected-error {{variable 'foo' with unknown type cannot be given a function type}} 35 } 36 } 37 38 namespace test4 { 39 extern __unknown_anytype test0(...); 40 extern __unknown_anytype test1(...); 41 test()42 void test() { 43 void (*fn)(int) = (void(*)(int)) test0; 44 int x = (int) test1; // expected-error {{function 'test1' with unknown type must be given a function type}} 45 } 46 } 47 48 namespace test5 { 49 template<typename T> struct X; // expected-note{{template is declared here}} 50 51 extern __unknown_anytype test0(...); 52 test()53 void test() { 54 (X<int>)test0(); // expected-error{{implicit instantiation of undefined template 'test5::X<int>'}} 55 } 56 } 57 58 namespace test6 { 59 extern __unknown_anytype func(); 60 extern __unknown_anytype var; 61 double *d; 62 test()63 void test() { 64 d = (double*)&func(); // expected-error{{address-of operator cannot be applied to a call to a function with unknown return type}} 65 d = (double*)&var; 66 } 67 68 } 69