diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-03-05 22:54:58 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-03-05 22:54:58 +0000 |
commit | ce29c52e27f55a2f4d08daccaace3d7d9ffcbb8a (patch) | |
tree | 6847438f580e73fcd49005af64b8483baff2ef9c | |
parent | a6e164986a074d181cc7db5c947421d749f96a30 (diff) | |
download | clang-ce29c52e27f55a2f4d08daccaace3d7d9ffcbb8a.tar.gz |
Tests for DR370-380.
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
-rw-r--r-- | include/clang/Basic/DiagnosticGroups.td | 1 | ||||
-rw-r--r-- | include/clang/Basic/DiagnosticSemaKinds.td | 9 | ||||
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 4 | ||||
-rw-r--r-- | test/CXX/drs/dr3xx.cpp | 108 | ||||
-rw-r--r-- | test/Misc/warning-flags.c | 4 | ||||
-rw-r--r-- | www/cxx_dr_status.html | 16 |
6 files changed, 125 insertions, 17 deletions
diff --git a/include/clang/Basic/DiagnosticGroups.td b/include/clang/Basic/DiagnosticGroups.td index 9ec2f421cd..ca12e4b73f 100644 --- a/include/clang/Basic/DiagnosticGroups.td +++ b/include/clang/Basic/DiagnosticGroups.td @@ -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 : diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index c23b5e25c4..1e2a5aae80 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -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">; diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 9870ab1e54..acf27e23c2 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -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; } } diff --git a/test/CXX/drs/dr3xx.cpp b/test/CXX/drs/dr3xx.cpp index 2784ca61ef..2d07ea3bc1 100644 --- a/test/CXX/drs/dr3xx.cpp +++ b/test/CXX/drs/dr3xx.cpp @@ -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 diff --git a/test/Misc/warning-flags.c b/test/Misc/warning-flags.c index 4f3519530c..7044a7828b 100644 --- a/test/Misc/warning-flags.c +++ b/test/Misc/warning-flags.c @@ -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 diff --git a/www/cxx_dr_status.html b/www/cxx_dr_status.html index ebd2869a69..2dfecb2c0a 100644 --- a/www/cxx_dr_status.html +++ b/www/cxx_dr_status.html @@ -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> |