Files
clang-p2996/clang/test/CXX/basic/basic.scope/basic.scope.local/p2.cpp
David Blaikie 1c9c90495d PR14296: function parameter name collisions in function try/catch
C++11 3.3.3/2 "A parameter name shall not be redeclared in the outermost block
of the function definition nor in the outermost block of any handler associated
with a function-try-block."

It's not totally clear to me whether the "FIXME" case is covered by this, but
Richard Smith thinks it probably should be. It's just a bit more involved to
fix that case.

llvm-svn: 167650
2012-11-10 01:04:23 +00:00

26 lines
734 B
C++

// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcxx-exceptions -fexceptions -verify %s
void func1(int i) { // expected-note{{previous definition is here}}
int i; // expected-error{{redefinition of 'i'}}
}
void func2(int i) try { // expected-note{{previous definition is here}}
int i; // expected-error{{redefinition of 'i'}}
} catch (...) {
}
void func3(int i) try { // FIXME: note {{previous definition is here}}
} catch (int i) { // FIXME: error {{redefinition of 'i'}}
}
void func4(int i) try { // expected-note{{previous definition is here}}
} catch (...) {
int i; // expected-error{{redefinition of 'i'}}
}
void func5() try {
int i;
} catch (...) {
int j = i; // expected-error{{use of undeclared identifier 'i'}}
}