blob: ccde3dcfb3123f81822b3c21c79e2450d8224da3 [file] [log] [blame]
Richard Smith762bb9d2011-10-13 22:29:44 +00001// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
Douglas Gregorf801dcf2010-07-15 18:35:15 +00002
3// PR5290
4int const f0();
5void f0_test() {
Douglas Gregor35e12c92010-07-15 18:47:04 +00006 decltype(0, f0()) i = 0;
Douglas Gregorf801dcf2010-07-15 18:35:15 +00007 i = 0;
8}
9
10struct A { int a[1]; A() { } };
11typedef A const AC;
12int &f1(int*);
13float &f2(int const*);
14
15void test_f2() {
16 float &fr = f2(AC().a);
17}
18
Francois Pichete3d49b42011-06-19 08:02:06 +000019namespace pr10154 {
20 class A{
21 A(decltype(nullptr) param);
22 };
Richard Smithfa161252012-01-15 06:24:57 +000023}
24
25template<typename T> struct S {};
26template<typename T> auto f(T t) -> decltype(S<int>(t)) {
27 using U = decltype(S<int>(t));
28 using U = S<int>;
29 return S<int>(t);
30}
Argyrios Kyrtzidis1e584692012-10-26 22:53:44 +000031
32struct B {
33 B(decltype(undeclared)); // expected-error {{undeclared identifier}}
34};
35struct C {
36 C(decltype(undeclared; // expected-error {{undeclared identifier}} \
37 // expected-error {{expected ')'}} expected-note {{to match this '('}}
38};
David Blaikieb578aee2012-11-07 19:08:05 +000039
40template<typename>
41class conditional {
42};
43
44void foo(conditional<decltype((1),int>) { // expected-note 2 {{to match this '('}} expected-error {{expected ')'}}
45} // expected-error {{expected function body after function declarator}} expected-error 2 {{expected '>'}} expected-error {{expected ')'}}