Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit 3be9678

Browse files
committed
Add a test for C++ [stmt.select]p3, which specifies that redeclaring a
name in the outermost block of a if/else that declares the same name is ill-formed. Turns out that Clang and MSVC were right about PR6739; GCC is too lax. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99937 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 6bb8017 commit 3be9678

File tree

1 file changed

+11
-0
lines changed
  • test/CXX/stmt.stmt/stmt.select

1 file changed

+11
-0
lines changed

Diff for: test/CXX/stmt.stmt/stmt.select/p3.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %clang_cc1 -fsyntax-only -verify %s
2+
3+
int f();
4+
5+
void g() {
6+
if (int x = f()) { // expected-note 2{{previous definition}}
7+
int x; // expected-error{{redefinition of 'x'}}
8+
} else {
9+
int x; // expected-error{{redefinition of 'x'}}
10+
}
11+
}

0 commit comments

Comments
 (0)