From: Richard Smith Date: Wed, 5 Mar 2014 22:54:58 +0000 (+0000) Subject: Tests for DR370-380. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ce29c52e27f55a2f4d08daccaace3d7d9ffcbb8a;p=clang 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 --- 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; +def ext_enumerator_increment_too_large : ExtWarn< + "incremented enumerator value %0 is not representable in the " + "largest integer type">, InGroup; 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 struct X { + protected: + typedef T Type; // expected-note 2{{protected}} + }; + template struct Y {}; + + // FIXME: These two are valid; deriving from T1 gives Z1 access to + // the protected member T1::Type. + template class T1, + template class T2> struct Z1 : + T1, + T2::Type> {}; // expected-error {{protected}} + + template class T1, + template class T2> struct Z2 : + T2::Type>, // expected-error {{protected}} + T1 {}; + + Z1 z1; // expected-note {{instantiation of}} + Z2 z2; // expected-note {{instantiation of}} + } + + namespace example2 { + struct X { + private: + typedef int Type; // expected-note {{private}} + }; + template struct A { + typename T::Type t; // expected-error {{private}} + }; + A ax; // expected-note {{instantiation of}} + } + + namespace example3 { + struct A { + protected: + typedef int N; // expected-note 2{{protected}} + }; + + template struct B {}; + template struct C : U, B {}; // expected-error {{protected}} + template struct D : B, U {}; // expected-error {{protected}} + + C x; // expected-note {{instantiation of}} + D 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 void f(); + template struct A { void f(); }; + } + template<> void N::f() {} + template<> void N::A::f() {} + template<> struct N::A {}; +#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 372 CD1 Is access granted by base class specifiers available in following base class specifiers? - Unknown + No 373 C++11 Lookup on namespace qualified name in using-directive - Unknown + No 374 CD2 Can explicit specialization outside namespace use qualified name? - Unknown + Yes (C++11 onwards) 375 dup Confusing example on lookup with typename - Unknown + Duplicate of 345 376 NAD Class "definition" versus class "declaration" - Unknown + N/A 377 CD1 Enum whose enumerators will not fit in any integral type - Unknown + Yes 378 CD1 Wording that says temporaries are declared - Unknown + Duplicate of 276 379 CD1 Change "class declaration" to "class definition" - Unknown + N/A 380