From 3be9678105f10c49c4ebc5ce353f770c3a50f9c7 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Tue, 30 Mar 2010 22:07:46 +0000 Subject: [PATCH] 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 --- test/CXX/stmt.stmt/stmt.select/p3.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 test/CXX/stmt.stmt/stmt.select/p3.cpp diff --git a/test/CXX/stmt.stmt/stmt.select/p3.cpp b/test/CXX/stmt.stmt/stmt.select/p3.cpp new file mode 100644 index 0000000000..e674f9708c --- /dev/null +++ b/test/CXX/stmt.stmt/stmt.select/p3.cpp @@ -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'}} + } +} -- 2.50.1