зеркало из https://github.com/microsoft/clang-1.git
In C++, one cannot assign from an arithmetic type to an enumeration
type. Fixes PR7051. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104475 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
26d1f75d5b
Коммит
88623ade95
|
@ -4650,7 +4650,8 @@ Sema::CheckAssignmentConstraints(QualType lhsType, QualType rhsType) {
|
|||
return Incompatible;
|
||||
}
|
||||
|
||||
if (lhsType->isArithmeticType() && rhsType->isArithmeticType())
|
||||
if (lhsType->isArithmeticType() && rhsType->isArithmeticType() &&
|
||||
!(getLangOptions().CPlusPlus && lhsType->isEnumeralType()))
|
||||
return Compatible;
|
||||
|
||||
if (isa<PointerType>(lhsType)) {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
// RUN: %clang_cc1 -fsyntax-only -pedantic -std=c++98 -verify -triple x86_64-apple-darwin %s
|
||||
|
||||
enum E {
|
||||
Val1,
|
||||
Val2
|
||||
|
@ -71,3 +70,12 @@ namespace PR6061 {
|
|||
namespace Conditional {
|
||||
enum a { A }; a x(const enum a x) { return 1?x:A; }
|
||||
}
|
||||
|
||||
namespace PR7051 {
|
||||
enum E { e0 };
|
||||
void f() {
|
||||
E e;
|
||||
e = 1; // expected-error{{assigning to 'PR7051::E' from incompatible type 'int'}}
|
||||
e |= 1; // expected-error{{assigning to 'PR7051::E' from incompatible type 'int'}}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче