]> granicus.if.org Git - clang/commitdiff
r184100 Fix -- Updated test cases for contextual conversion
authorLarisse Voufo <lvoufo@google.com>
Tue, 18 Jun 2013 01:27:47 +0000 (01:27 +0000)
committerLarisse Voufo <lvoufo@google.com>
Tue, 18 Jun 2013 01:27:47 +0000 (01:27 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184165 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExprCXX.cpp
test/SemaCXX/cxx1y-contextual-conversion-tweaks.cpp
test/SemaCXX/cxx98-compat-pedantic.cpp

index 40af2075c3f5861943948398586cd7e6a22f678f..d723c1fe77dc995826cc3f7b39563be661ae1def 100644 (file)
@@ -1205,9 +1205,9 @@ Sema::BuildCXXNew(SourceRange Range, bool UseGlobal,
                                                AA_Converting);
 
       if (!isSFINAEContext())
-       // Diagnose the compatibility of this conversion.
-       Diag(StartLoc, diag::warn_cxx98_compat_array_size_conversion)
-         << ArraySize->getType() << 0 << Context.getSizeType();
+        // Diagnose the compatibility of this conversion.
+        Diag(StartLoc, diag::warn_cxx98_compat_array_size_conversion)
+          << ArraySize->getType() << 0 << "'size_t'";
     } else {
       class SizeConvertDiagnoser : public ICEConvertDiagnoser {
       protected:
index f00bf1ea3104a61d4cebc6f568d41d630a2214db..58bbbb2a04421f0fcba7f09098de5ccac844c2b9 100644 (file)
@@ -154,4 +154,24 @@ namespace extended_examples_cxx1y {
 //expected-error@143 {{cannot initialize object parameter of type 'extended_examples_cxx1y::D' with an expression of type 'extended_examples_cxx1y::D'}}
 #endif
 
-// FIXME: Extend with more examples, including [expr.const] and [expr.new].
+namespace extended_examples_array_bounds {
+  
+  typedef decltype(sizeof(int)) size_t;
+  
+  struct Foo {
+    operator size_t();   // @162
+    operator unsigned short();  // @163
+  };
+
+  void bar() {
+    Foo x;
+    int *p = new int[x];        // @168
+  }
+}
+
+#ifdef CXX1Y
+#else
+//expected-error@168 {{ambiguous conversion of array size expression of type 'extended_examples_array_bounds::Foo' to an integral or enumeration type}}
+//expected-note@162 {{conversion to integral type 'size_t'}}
+//expected-note@163 {{conversion to integral type 'unsigned short' declared here}}
+#endif
index 5fe7980994e533c661b8ad8f56eea28efdeed9d9..50ce6a49002ee5d9bb73d0d8db114dc74969f0ee 100644 (file)
@@ -34,7 +34,7 @@ struct ConvertToInt {
 };
 int *ArraySizeConversion = new int[ConvertToInt()];
 #ifdef CXX1Y2
-// expected-warning@-2 {{implicit conversion from array size expression of type 'ConvertToInt' to integral type}} // 'unsigned long' is incompatible with C++98}}
+// expected-warning@-2 {{implicit conversion from array size expression of type 'ConvertToInt' to integral type 'size_t' is incompatible with C++98}}
 #else
 // expected-warning@-4 {{implicit conversion from array size expression of type 'ConvertToInt' to integral type 'int' is incompatible with C++98}}
 #endif