[cfe-commits] r113711 - in /cfe/trunk: lib/Sema/SemaOverload.cpp test/SemaCXX/enum.cpp
Douglas Gregor
dgregor at apple.com
Sat Sep 11 20:38:25 PDT 2010
Author: dgregor
Date: Sat Sep 11 22:38:25 2010
New Revision: 113711
URL: http://llvm.org/viewvc/llvm-project?rev=113711&view=rev
Log:
Don't perform integral promotions from an incompletion enumeration
type. Fixes PR8089 in a slightly different way than had been suggested.
Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/SemaCXX/enum.cpp
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=113711&r1=113710&r2=113711&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Sat Sep 11 22:38:25 2010
@@ -1194,7 +1194,8 @@
// We pre-calculate the promotion type for enum types.
if (const EnumType *FromEnumType = FromType->getAs<EnumType>())
- if (ToType->isIntegerType())
+ if (ToType->isIntegerType() &&
+ !RequireCompleteType(From->getLocStart(), FromType, PDiag()))
return Context.hasSameUnqualifiedType(ToType,
FromEnumType->getDecl()->getPromotionType());
Modified: cfe/trunk/test/SemaCXX/enum.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/enum.cpp?rev=113711&r1=113710&r2=113711&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/enum.cpp (original)
+++ cfe/trunk/test/SemaCXX/enum.cpp Sat Sep 11 22:38:25 2010
@@ -90,3 +90,8 @@
enum PR7921E {
PR7921V = (PR7921E)(123) // expected-error {{expression is not an integer constant expression}}
};
+
+void PR8089() {
+ enum E; // expected-error{{ISO C++ forbids forward references to 'enum' types}}
+ int a = (E)3; // expected-error{{cannot initialize a variable of type 'int' with an rvalue of type 'E'}}
+}
More information about the cfe-commits
mailing list