Author: rsmith
Date: Thu Dec 20 12:58:53 2018
New Revision: 349820

URL: http://llvm.org/viewvc/llvm-project?rev=349820&view=rev
Log:
Make the "too many braces in scalar initialization" extension cause
SFINAE failures.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/test/SemaCXX/cxx0x-initializer-scalars.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=349820&r1=349819&r2=349820&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Dec 20 12:58:53 
2018
@@ -4880,7 +4880,7 @@ def warn_braces_around_scalar_init : War
   "braces around scalar initializer">, 
InGroup<DiagGroup<"braced-scalar-init">>;
 def ext_many_braces_around_scalar_init : ExtWarn<
   "too many braces around scalar initializer">,
-  InGroup<DiagGroup<"many-braces-around-scalar-init">>;
+  InGroup<DiagGroup<"many-braces-around-scalar-init">>, SFINAEFailure;
 def ext_complex_component_init : Extension<
   "complex initialization specifying real and imaginary components "
   "is an extension">, InGroup<DiagGroup<"complex-component-init">>;

Modified: cfe/trunk/test/SemaCXX/cxx0x-initializer-scalars.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx0x-initializer-scalars.cpp?rev=349820&r1=349819&r2=349820&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx0x-initializer-scalars.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx0x-initializer-scalars.cpp Thu Dec 20 12:58:53 
2018
@@ -127,3 +127,26 @@ namespace PR12118 {
     static_assert(sizeof(f({0})) == sizeof(one), "bad overload");
   }
 }
+
+namespace excess_braces_sfinae {
+  using valid = int&;
+  using invalid = float&;
+
+  template<typename T> valid braces1(decltype(T{0})*);
+  template<typename T> invalid braces1(...);
+
+  template<typename T> valid braces2(decltype(T{{0}})*);
+  template<typename T> invalid braces2(...);
+
+  template<typename T> valid braces3(decltype(T{{{0}}})*);
+  template<typename T> invalid braces3(...);
+
+  valid a = braces1<int>(0);
+  invalid b = braces2<int>(0);
+  invalid c = braces3<int>(0);
+
+  struct X { int n; };
+  valid d = braces1<X>(0);
+  valid e = braces2<X>(0);
+  invalid f = braces3<X>(0);
+}


_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to