From b0a58cd0d69d213b6cd1e6a7bb7319f4f270944b Mon Sep 17 00:00:00 2001 From: Francois Pichet Date: Thu, 18 Aug 2011 00:04:08 +0000 Subject: [PATCH] Downgrade "err_init_list_variable_narrowing" into a warning in Microsoft mode even if c++0x is enabled. This necessary to parse MSVC code in C++0x mode. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137904 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaInit.cpp | 4 ++-- test/SemaCXX/microsoft-cxx0x.cpp | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 test/SemaCXX/microsoft-cxx0x.cpp diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index e410f2f9a0..ee122ff05d 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -5145,7 +5145,7 @@ static void DiagnoseNarrowingInInitList( bool Constant, const APValue &ConstantValue) { if (Constant) { S.Diag(InitE->getLocStart(), - S.getLangOptions().CPlusPlus0x + S.getLangOptions().CPlusPlus0x && !S.getLangOptions().Microsoft ? diag::err_init_list_constant_narrowing : diag::warn_init_list_constant_narrowing) << InitE->getSourceRange() @@ -5153,7 +5153,7 @@ static void DiagnoseNarrowingInInitList( << EntityType; } else S.Diag(InitE->getLocStart(), - S.getLangOptions().CPlusPlus0x + S.getLangOptions().CPlusPlus0x && !S.getLangOptions().Microsoft ? diag::err_init_list_variable_narrowing : diag::warn_init_list_variable_narrowing) << InitE->getSourceRange() diff --git a/test/SemaCXX/microsoft-cxx0x.cpp b/test/SemaCXX/microsoft-cxx0x.cpp new file mode 100644 index 0000000000..ae2219b143 --- /dev/null +++ b/test/SemaCXX/microsoft-cxx0x.cpp @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -Wc++0x-narrowing -Wmicrosoft -verify -fms-extensions -std=c++0x + + +struct A { + unsigned int a; +}; +int b = 3; +A var = { b }; // expected-warning {{ cannot be narrowed }} expected-note {{override}} + + -- 2.40.0