[cfe-commits] r91563 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/SemaCXX/enum.cpp
Eli Friedman
eli.friedman at gmail.com
Wed Dec 16 12:30:08 PST 2009
Author: efriedma
Date: Wed Dec 16 14:30:08 2009
New Revision: 91563
URL: http://llvm.org/viewvc/llvm-project?rev=91563&view=rev
Log:
Make sure C-specific enum warning doesn't trigger in C++.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/enum.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=91563&r1=91562&r2=91563&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Dec 16 14:30:08 2009
@@ -5812,7 +5812,7 @@
const llvm::APSInt &InitVal = ECD->getInitVal();
assert(InitVal.getBitWidth() >= IntWidth &&
"Should have promoted value to int");
- if (InitVal.getBitWidth() > IntWidth) {
+ if (!getLangOptions().CPlusPlus && InitVal.getBitWidth() > IntWidth) {
llvm::APSInt V(InitVal);
V.trunc(IntWidth);
V.extend(InitVal.getBitWidth());
Modified: cfe/trunk/test/SemaCXX/enum.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/enum.cpp?rev=91563&r1=91562&r2=91563&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/enum.cpp (original)
+++ cfe/trunk/test/SemaCXX/enum.cpp Wed Dec 16 14:30:08 2009
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -pedantic -std=c++98 -verify %s
enum E {
Val1,
@@ -42,26 +42,26 @@
template <class A> struct is_same<A,A> { static const int value = 1; };
enum enum0 { v0 };
- int test0[is_same<typeof(+v0), int>::value];
+ int test0[is_same<__typeof(+v0), int>::value];
enum enum1 { v1 = __INT_MAX__ };
- int test1[is_same<typeof(+v1), int>::value];
+ int test1[is_same<__typeof(+v1), int>::value];
enum enum2 { v2 = __INT_MAX__ * 2U };
- int test2[is_same<typeof(+v2), unsigned int>::value];
+ int test2[is_same<__typeof(+v2), unsigned int>::value];
// This kindof assumes that 'int' is smaller than 'long long'.
#if defined(__LP64__)
- enum enum3 { v3 = __LONG_LONG_MAX__ };
- int test3[is_same<typeof(+v3), long>::value];
+ enum enum3 { v3 = __LONG_MAX__ };
+ int test3[is_same<__typeof(+v3), long>::value];
- enum enum4 { v4 = __LONG_LONG_MAX__ * 2ULL };
- int test4[is_same<typeof(+v4), unsigned long>::value];
+ enum enum4 { v4 = __LONG_MAX__ * 2UL };
+ int test4[is_same<__typeof(+v4), unsigned long>::value];
#else
enum enum3 { v3 = __LONG_LONG_MAX__ };
- int test3[is_same<typeof(+v3), long long>::value];
+ int test3[is_same<__typeof(+v3), long long>::value]; // expected-warning {{'long long' is an extension}}
- enum enum4 { v4 = __LONG_LONG_MAX__ * 2ULL };
- int test4[is_same<typeof(+v4), unsigned long long>::value];
+ enum enum4 { v4 = __LONG_LONG_MAX__ * 2ULL }; // expected-warning {{'long long' is an extension}}
+ int test4[is_same<__typeof(+v4), unsigned long long>::value]; // expected-warning {{'long long' is an extension}}
#endif
}
More information about the cfe-commits
mailing list