]> granicus.if.org Git - clang/commitdiff
Add a test for C++ [stmt.select]p3, which specifies that redeclaring a
authorDouglas Gregor <dgregor@apple.com>
Tue, 30 Mar 2010 22:07:46 +0000 (22:07 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 30 Mar 2010 22:07:46 +0000 (22:07 +0000)
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

test/CXX/stmt.stmt/stmt.select/p3.cpp [new file with mode: 0644]

diff --git a/test/CXX/stmt.stmt/stmt.select/p3.cpp b/test/CXX/stmt.stmt/stmt.select/p3.cpp
new file mode 100644 (file)
index 0000000..e674f97
--- /dev/null
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int f();
+
+void g() {
+  if (int x = f()) { // expected-note 2{{previous definition}}
+    int x; // expected-error{{redefinition of 'x'}}
+  } else {
+    int x; // expected-error{{redefinition of 'x'}}
+  }
+}