p2.cpp revision e7397c6a1bb2b205c5fe678e26199eb26d22e38e
1// RUN: %clang_cc1 -fexceptions -fsyntax-only -verify %s -std=c++0x 2 3struct S { 4 virtual ~S(); 5 6 void g() throw (auto(*)()->int); 7 8 // Note, this is not permitted: conversion-declarator cannot have a trailing return type. 9 // FIXME: don't issue the second diagnostic for this. 10 operator auto(*)()->int(); // expected-error{{'auto' not allowed here}} expected-error {{C++ requires a type specifier}} 11}; 12 13typedef auto Fun(int a) -> decltype(a + a); 14typedef auto (*PFun)(int a) -> decltype(a + a); 15 16void g(auto (*f)() -> int) { 17 try { } 18 catch (auto (&f)() -> int) { } 19 catch (auto (*const f[10])() -> int) { } 20} 21 22namespace std { 23 class type_info; 24} 25 26template<typename T> struct U {}; 27 28void j() { 29 (void)typeid(auto(*)()->void); 30 (void)sizeof(auto(*)()->void); 31 (void)__alignof(auto(*)()->void); 32 33 U<auto(*)()->void> v; 34 35 int n; 36 (void)static_cast<auto(*)()->void>(&j); 37 auto p = reinterpret_cast<auto(*)()->int>(&j); 38 (void)const_cast<auto(**)()->int>(&p); 39 (void)(auto(*)()->void)(&j); 40} 41 42template <auto (*f)() -> void = &j> class C { }; 43struct F : auto(*)()->int {}; // expected-error{{expected class name}} 44template<typename T = auto(*)()->int> struct G { }; 45 46int g(); 47auto (*h)() -> auto = &g; // expected-error{{'auto' not allowed here}} 48auto (*i)() = &g; // ok; auto deduced as int. 49auto (*k)() -> int = i; // ok; no deduction. 50