]> granicus.if.org Git - clang/commitdiff
Tests for DR370-380.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 5 Mar 2014 22:54:58 +0000 (22:54 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 5 Mar 2014 22:54:58 +0000 (22:54 +0000)
Also promote a couple of Warnings on ill-formed code found by this testing to
ExtWarns.

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

include/clang/Basic/DiagnosticGroups.td
include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaDecl.cpp
test/CXX/drs/dr3xx.cpp
test/Misc/warning-flags.c
www/cxx_dr_status.html

index 9ec2f421cda34a2afd75d9e5a0830931bd2fba85..ca12e4b73feb4e9bb3b4a1c23626493b173b13b8 100644 (file)
@@ -41,6 +41,7 @@ def SignConversion : DiagGroup<"sign-conversion">;
 def BoolConversion : DiagGroup<"bool-conversion">;
 def IntConversion : DiagGroup<"int-conversion">;
 def EnumConversion : DiagGroup<"enum-conversion">;
+def EnumTooLarge : DiagGroup<"enum-too-large">;
 def NonLiteralNullConversion : DiagGroup<"non-literal-null-conversion">;
 def NullConversion : DiagGroup<"null-conversion">;
 def ImplicitConversionFloatingPointToBool :
index c23b5e25c4e9baccba52c80db9760d73180832a1..1e2a5aae8030416ebe7f47a2a1171c3efc0df0c5 100644 (file)
@@ -3774,10 +3774,11 @@ def warn_ivars_in_interface : Warning<
 def ext_enum_value_not_int : Extension<
   "ISO C restricts enumerator values to range of 'int' (%0 is too "
   "%select{small|large}1)">;
-def warn_enum_too_large : Warning<
-  "enumeration values exceed range of largest integer">;
-def warn_enumerator_too_large : Warning<
-  "enumerator value %0 is not representable in the largest integer type">;
+def ext_enum_too_large : ExtWarn<
+  "enumeration values exceed range of largest integer">, InGroup<EnumTooLarge>;
+def ext_enumerator_increment_too_large : ExtWarn<
+  "incremented enumerator value %0 is not representable in the "
+  "largest integer type">, InGroup<EnumTooLarge>;
   
 def warn_illegal_constant_array_size : Extension<
   "size of static array must be an integer constant expression">;
index 9870ab1e5425797e583c243bf9f917845de65ad8..acf27e23c2e1cee5c596aa577494a7d6eb8660a6 100644 (file)
@@ -12452,7 +12452,7 @@ EnumConstantDecl *Sema::CheckEnumConstant(EnumDecl *Enum,
               << EnumVal.toString(10)
               << EltTy;
           else
-            Diag(IdLoc, diag::warn_enumerator_too_large)
+            Diag(IdLoc, diag::ext_enumerator_increment_too_large)
               << EnumVal.toString(10);
         } else {
           EltTy = T;
@@ -12850,7 +12850,7 @@ void Sema::ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc,
         BestWidth = Context.getTargetInfo().getLongLongWidth();
 
         if (NumNegativeBits > BestWidth || NumPositiveBits >= BestWidth)
-          Diag(Enum->getLocation(), diag::warn_enum_too_large);
+          Diag(Enum->getLocation(), diag::ext_enum_too_large);
         BestType = Context.LongLongTy;
       }
     }
index 2784ca61efe22d1143c6c574fcdaea4b92649307..2d07ea3bc19c1bd100f22ae9d39c763210431bf9 100644 (file)
@@ -816,3 +816,111 @@ namespace dr368 { // dr368: yes
 }
 
 // dr370: na
+
+namespace dr372 { // dr372: no
+  namespace example1 {
+    template<typename T> struct X {
+    protected:
+      typedef T Type; // expected-note 2{{protected}}
+    };
+    template<typename T> struct Y {};
+
+    // FIXME: These two are valid; deriving from T1<T> gives Z1 access to
+    // the protected member T1<T>::Type.
+    template<typename T,
+             template<typename> class T1,
+             template<typename> class T2> struct Z1 :
+      T1<T>,
+      T2<typename T1<T>::Type> {}; // expected-error {{protected}}
+
+    template<typename T,
+             template<typename> class T1,
+             template<typename> class T2> struct Z2 :
+      T2<typename T1<T>::Type>, // expected-error {{protected}}
+      T1<T> {};
+
+    Z1<int, X, Y> z1; // expected-note {{instantiation of}}
+    Z2<int, X, Y> z2; // expected-note {{instantiation of}}
+  }
+
+  namespace example2 {
+    struct X {
+    private:
+      typedef int Type; // expected-note {{private}}
+    };
+    template<typename T> struct A {
+      typename T::Type t; // expected-error {{private}}
+    };
+    A<X> ax; // expected-note {{instantiation of}}
+  }
+
+  namespace example3 {
+    struct A {
+    protected:
+      typedef int N; // expected-note 2{{protected}}
+    };
+
+    template<typename T> struct B {};
+    template<typename U> struct C : U, B<typename U::N> {}; // expected-error {{protected}}
+    template<typename U> struct D : B<typename U::N>, U {}; // expected-error {{protected}}
+
+    C<A> x; // expected-note {{instantiation of}}
+    D<A> y; // expected-note {{instantiation of}}
+  }
+
+  namespace example4 {
+    class A {
+      class B {};
+      friend class X;
+    };
+
+    struct X : A::B {
+      A::B mx;
+      class Y {
+        A::B my;
+      };
+    };
+  }
+}
+
+namespace dr373 { // dr373: no
+  // FIXME: This is valid.
+  namespace X { int dr373; } // expected-note 2{{here}}
+  struct dr373 { // expected-note {{here}}
+    void f() {
+      using namespace dr373::X; // expected-error {{no namespace named 'X' in 'dr373::dr373'}}
+      int k = dr373; // expected-error {{does not refer to a value}}
+
+      namespace Y = dr373::X; // expected-error {{no namespace named 'X' in 'dr373::dr373'}}
+      k = Y::dr373;
+    }
+  };
+}
+
+namespace dr374 { // dr374: yes c++11
+  namespace N {
+    template<typename T> void f();
+    template<typename T> struct A { void f(); };
+  }
+  template<> void N::f<char>() {}
+  template<> void N::A<char>::f() {}
+  template<> struct N::A<int> {};
+#if __cplusplus < 201103L
+  // expected-error@-4 {{extension}} expected-note@-7 {{here}}
+  // expected-error@-4 {{extension}} expected-note@-7 {{here}}
+  // expected-error@-4 {{extension}} expected-note@-8 {{here}}
+#endif
+}
+
+// dr375: dup 345
+// dr376: na
+
+namespace dr377 { // dr377: yes
+  enum E { // expected-error {{enumeration values exceed range of largest integer}}
+    a = -__LONG_LONG_MAX__ - 1, // expected-error 0-1{{extension}}
+    b = 2 * (unsigned long long)__LONG_LONG_MAX__ // expected-error 0-2{{extension}}
+  };
+}
+
+// dr378: dup 276
+// dr379: na
index 4f3519530cf6f4a801604e6000a333ac8d90791e..7044a7828b611a2adf294948a3b38cd5452c1aff 100644 (file)
@@ -18,7 +18,7 @@ This test serves two purposes:
 
 The list of warnings below should NEVER grow.  It should gradually shrink to 0.
 
-CHECK: Warnings without flags (111):
+CHECK: Warnings without flags (109):
 CHECK-NEXT:   ext_delete_void_ptr_operand
 CHECK-NEXT:   ext_expected_semi_decl_list
 CHECK-NEXT:   ext_explicit_specialization_storage_class
@@ -69,9 +69,7 @@ CHECK-NEXT:   warn_drv_objc_gc_unsupported
 CHECK-NEXT:   warn_drv_pch_not_first_include
 CHECK-NEXT:   warn_dup_category_def
 CHECK-NEXT:   warn_duplicate_protocol_def
-CHECK-NEXT:   warn_enum_too_large
 CHECK-NEXT:   warn_enum_value_overflow
-CHECK-NEXT:   warn_enumerator_too_large
 CHECK-NEXT:   warn_exception_caught_by_earlier_handler
 CHECK-NEXT:   warn_excess_initializers
 CHECK-NEXT:   warn_excess_initializers_in_char_array_initializer
index ebd2869a69bec1cb19d62174bd8260e88d4f3320..2dfecb2c0a32ecd3d6e546dc26e502ad60d9475d 100644 (file)
@@ -2273,49 +2273,49 @@ of class templates</td>
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#372">372</a></td>
     <td>CD1</td>
     <td>Is access granted by base class specifiers available in following base class specifiers?</td>
-    <td class="none" align="center">Unknown</td>
+    <td class="none" align="center">No</td>
   </tr>
   <tr>
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#373">373</a></td>
     <td>C++11</td>
     <td>Lookup on namespace qualified name in using-directive</td>
-    <td class="none" align="center">Unknown</td>
+    <td class="none" align="center">No</td>
   </tr>
   <tr>
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#374">374</a></td>
     <td>CD2</td>
     <td>Can explicit specialization outside namespace use qualified name?</td>
-    <td class="none" align="center">Unknown</td>
+    <td class="full" align="center">Yes (C++11 onwards)</td>
   </tr>
   <tr>
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#375">375</a></td>
     <td>dup</td>
     <td>Confusing example on lookup with <TT>typename</TT></td>
-    <td class="none" align="center">Unknown</td>
+    <td class="full" align="center">Duplicate of 345</td>
   </tr>
   <tr>
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#376">376</a></td>
     <td>NAD</td>
     <td>Class "definition" versus class "declaration"</td>
-    <td class="none" align="center">Unknown</td>
+    <td class="na" align="center">N/A</td>
   </tr>
   <tr>
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#377">377</a></td>
     <td>CD1</td>
     <td>Enum whose enumerators will not fit in any integral type</td>
-    <td class="none" align="center">Unknown</td>
+    <td class="full" align="center">Yes</td>
   </tr>
   <tr>
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#378">378</a></td>
     <td>CD1</td>
     <td>Wording that says temporaries are declared</td>
-    <td class="none" align="center">Unknown</td>
+    <td class="na" align="center">Duplicate of 276</td>
   </tr>
   <tr>
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#379">379</a></td>
     <td>CD1</td>
     <td>Change "class declaration" to "class definition"</td>
-    <td class="none" align="center">Unknown</td>
+    <td class="na" align="center">N/A</td>
   </tr>
   <tr class="open">
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#380">380</a></td>