summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/try-catch.cpp
blob: 653deaa5fbca6cb0c8380039ee96dfd87174492d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// RUN: clang-cc -fsyntax-only -verify %s

struct A; // expected-note 3 {{forward declaration of 'struct A'}}

void f()
{
  try {
  } catch(int i) { // expected-note {{previous definition}}
    int j = i;
    int i; // expected-error {{redefinition of 'i'}}
  } catch(float i) {
  } catch(void v) { // expected-error {{cannot catch incomplete type 'void'}}
  } catch(A a) { // expected-error {{cannot catch incomplete type 'struct A'}}
  } catch(A *a) { // expected-error {{cannot catch pointer to incomplete type 'struct A'}}
  } catch(A &a) { // expected-error {{cannot catch reference to incomplete type 'struct A'}}
  } catch(...) {
    int j = i; // expected-error {{use of undeclared identifier 'i'}}
  }

  try {
  } catch(...) { // expected-error {{catch-all handler must come last}}
  } catch(int) {
  }
}
OpenPOWER on IntegriCloud