]> granicus.if.org Git - clang/commitdiff
Make the "too many braces in scalar initialization" extension cause
authorRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 20 Dec 2018 20:58:53 +0000 (20:58 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 20 Dec 2018 20:58:53 +0000 (20:58 +0000)
SFINAE failures.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@349820 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.td
test/SemaCXX/cxx0x-initializer-scalars.cpp

index 9ab263fcfe513c2036a81b62c9c9553641e1047a..91df49b80c51a6f62c6ec976fd2f08392d1fd6a7 100644 (file)
@@ -4880,7 +4880,7 @@ def warn_braces_around_scalar_init : Warning<
   "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">>;
index 90b11f3a9e2303a1b408f4f468d46cff21f5ca2c..a13aa238de663cfb4221861384f8a025780f71f9 100644 (file)
@@ -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);
+}