]> granicus.if.org Git - clang/commitdiff
Downgrade "err_init_list_variable_narrowing" into a warning in Microsoft mode even...
authorFrancois Pichet <pichet2000@gmail.com>
Thu, 18 Aug 2011 00:04:08 +0000 (00:04 +0000)
committerFrancois Pichet <pichet2000@gmail.com>
Thu, 18 Aug 2011 00:04:08 +0000 (00:04 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137904 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaInit.cpp
test/SemaCXX/microsoft-cxx0x.cpp [new file with mode: 0644]

index e410f2f9a0d7fca40b6032b7f1e023f8700b7de8..ee122ff05d622f11e0647e5c09bb9068b73da679 100644 (file)
@@ -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 (file)
index 0000000..ae2219b
--- /dev/null
@@ -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}}
+
+