aboutsummaryrefslogtreecommitdiff
path: root/test/SemaCXX/try-catch.cpp
blob: 97dbaee10de65443c71a623b63c35c4e890891c6 (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 -fsyntax-only -verify %s

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) {
  }
}