Clang Project

clang_source_code/test/SemaCXX/pr36536.cpp
1// RUN: %clang_cc1 -std=c++11 %s -verify -fno-spell-checking
2
3// These test cases are constructed to make clang call ActOnStartOfFunctionDef
4// with nullptr.
5
6struct ImplicitDefaultCtor1 {};
7struct Foo {
8  typedef int NameInClass;
9  void f();
10};
11namespace bar {
12// FIXME: Improved our recovery to make this a redeclaration of Foo::f,
13// even though this is in the wrong namespace. That will allow name lookup to
14// find NameInClass below. Users are likely to hit this when they forget to
15// close namespaces.
16// expected-error@+1 {{cannot define or redeclare 'f' here}}
17void Foo::f() {
18  switch (0) { case 0: ImplicitDefaultCtor1 o; }
19  // expected-error@+1 {{unknown type name 'NameInClass'}}
20  NameInClass var;
21}
22} // namespace bar
23
24struct ImplicitDefaultCtor2 {};
25template <typename T> class TFoo { void f(); };
26// expected-error@+1 {{nested name specifier 'decltype(TFoo<T>())::'}}
27template <typename T> void decltype(TFoo<T>())::f() {
28  switch (0) { case 0: ImplicitDefaultCtor1 o; }
29}
30
31namespace tpl2 {
32struct ImplicitDefaultCtor3 {};
33template <class T1> class A {
34  template <class T2> class B {
35    void mf2();
36  };
37};
38template <class Y>
39template <>
40// expected-error@+1 {{nested name specifier 'A<Y>::B<double>::'}}
41void A<Y>::B<double>::mf2() {
42  switch (0) { case 0: ImplicitDefaultCtor3 o; }
43}
44}
45