offset-of-like expressions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55627
91177308-0d34-0410-b5e6-
96231b3b80d8
if (SubExpr->getType()->isArithmeticType())
return CheckArithmeticConstantExpression(SubExpr);
+ if (SubExpr->getType()->isPointerType()) {
+ const Expr* Base = FindExpressionBaseAddress(SubExpr);
+ // If the pointer has a null base, this is an offsetof-like construct
+ if (!Base)
+ return CheckAddressConstantExpression(SubExpr);
+ }
+
Diag(Init->getExprLoc(),
diag::err_init_element_not_constant, Init->getSourceRange());
return true;
int f3(int x) { return x; }
typedef void (*vfunc)(void);
void *bar = (vfunc) f3;
+
+// PR2747
+struct sym_reg {
+ char nc_gpreg;
+};
+int sym_fw1a_scr[] = {
+ ((int)(&((struct sym_reg *)0)->nc_gpreg)) & 0
+};