From: Douglas Gregor Date: Mon, 25 Mar 2013 22:22:35 +0000 (+0000) Subject: Allow forward declaration of enums with a fixed underlying... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=abde2c7f2c0699c7db395166f4e89b80bb87bf67;p=clang Allow forward declaration of enums with a fixed underlying type in Objective-C (as well as C++11). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177930 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 5597bf6009..cb05bb0099 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -9858,7 +9858,8 @@ CreateNewDecl: // If this is an undefined enum, warn. if (TUK != TUK_Definition && !Invalid) { TagDecl *Def; - if (getLangOpts().CPlusPlus11 && cast(New)->isFixed()) { + if ((getLangOpts().CPlusPlus11 || getLangOpts().ObjC2) && + cast(New)->isFixed()) { // C++0x: 7.2p2: opaque-enum-declaration. // Conflicts are diagnosed above. Do nothing. } diff --git a/test/SemaObjC/enum-fixed-type.m b/test/SemaObjC/enum-fixed-type.m index 6fd400a637..c00e45a03e 100644 --- a/test/SemaObjC/enum-fixed-type.m +++ b/test/SemaObjC/enum-fixed-type.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s #if !__has_feature(objc_fixed_enum) # error Enumerations with a fixed underlying type are not supported @@ -28,9 +28,9 @@ void test() { // typedef enum : long { Foo } IntegerEnum; -int arr[(sizeof(typeof(Foo)) == sizeof(typeof(IntegerEnum))) - 1]; -int arr1[(sizeof(typeof(Foo)) == sizeof(typeof(long))) - 1]; -int arr2[(sizeof(typeof(IntegerEnum)) == sizeof(typeof(long))) - 1]; +int arr[(sizeof(__typeof__(Foo)) == sizeof(__typeof__(IntegerEnum)))? 1 : -1]; +int arr1[(sizeof(__typeof__(Foo)) == sizeof(__typeof__(long)))? 1 : -1]; +int arr2[(sizeof(__typeof__(IntegerEnum)) == sizeof(__typeof__(long)))? 1 : -1]; // typedef enum : long long { Bar = -1 } LongLongEnum;