"expression is not assignable")
DIAG(err_typecheck_incomplete_type_not_modifiable_lvalue, ERROR,
"incomplete type '%0' is not assignable")
+
DIAG(err_typecheck_duplicate_vector_components_not_mlvalue, ERROR,
"vector is not assignable (contains duplicate components)")
DIAG(err_typecheck_call_not_function, ERROR,
return BT->getKind() >= BuiltinType::Bool &&
BT->getKind() <= BuiltinType::LongLong;
if (const TagType *TT = dyn_cast<TagType>(CanonicalType))
- if (TT->getDecl()->isEnum())
+ // Incomplete enum types are not treated as integer types.
+ if (TT->getDecl()->isEnum() && TT->getDecl()->isDefinition())
return true;
if (const VectorType *VT = dyn_cast<VectorType>(CanonicalType))
return VT->getElementType()->isIntegerType();
return BT->getKind() >= BuiltinType::Bool &&
BT->getKind() <= BuiltinType::LongLong;
if (const TagType *TT = dyn_cast<TagType>(CanonicalType))
- if (TT->getDecl()->isEnum())
- return true;
+ if (TT->getDecl()->isEnum() && TT->getDecl()->isDefinition())
+ return true; // Complete enum types are integral.
if (const ASQualType *ASQT = dyn_cast<ASQualType>(CanonicalType))
return ASQT->getBaseType()->isIntegralType();
return false;
return BT->getKind() >= BuiltinType::Bool &&
BT->getKind() <= BuiltinType::LongDouble;
if (const TagType *TT = dyn_cast<TagType>(CanonicalType))
- return TT->getDecl()->isEnum();
+ return TT->getDecl()->isEnum() && TT->getDecl()->isDefinition();
if (const VectorType *VT = dyn_cast<VectorType>(CanonicalType))
return VT->getElementType()->isRealType();
if (const ASQualType *ASQT = dyn_cast<ASQualType>(CanonicalType))
if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
return BT->getKind() != BuiltinType::Void;
if (const TagType *TT = dyn_cast<TagType>(CanonicalType)) {
- if (TT->getDecl()->isEnum())
+ // Enums are scalar types, but only if they are defined. Incomplete enums
+ // are not treated as scalar types.
+ if (TT->getDecl()->isEnum() && TT->getDecl()->isDefinition())
return true;
return false;
}
Sema::StmtResult Sema::ActOnExprStmt(ExprTy *expr) {
Expr *E = static_cast<Expr*>(expr);
assert(E && "ActOnExprStmt(): missing expression");
+
+ // C99 6.8.3p2: The expression in an expression statement is evaluated as a
+ // void expression for its side effects. Conversion to void allows any
+ // operand, even incomplete types.
+
+ // Same thing in for stmt first clause (when expr) and third clause.
return E;
}
if (!SecondType->isScalarType()) // C99 6.8.5p2
return Diag(ForLoc, diag::err_typecheck_statement_requires_scalar,
- SecondType.getAsString(), Second->getSourceRange());
+ SecondType.getAsString(), Second->getSourceRange());
}
return new ForStmt(First, Second, Third, Body, ForLoc);
}
union u0; // expected-error {{previous use is here}}
enum u0 { U0A }; // expected-error {{error: use of 'u0' with tag type that does not match previous declaration}}
+
+// rdar://6095136
+extern enum some_undefined_enum ve2; // expected-warning {{ISO C forbids forward references to 'enum' types}}
+
+void test4() {
+ for (; ve2;) // expected-error {{statement requires expression of scalar type}}
+ ;
+ (_Bool)ve2; // expected-error {{statement requires expression of scalar type}}
+
+ for (; ;ve2)
+ ;
+ (void)ve2;
+ ve2;
+}
+