Mordante updated this revision to Diff 285704.
Mordante marked an inline comment as done.
Mordante added a comment.
Addresses review comments.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D85601/new/
https://reviews.llvm.org/D85601
Files:
clang/lib/Sema/SemaChecking.cpp
clang/test/SemaCXX/conditional-expr.cpp
Index: clang/test/SemaCXX/conditional-expr.cpp
===================================================================
--- clang/test/SemaCXX/conditional-expr.cpp
+++ clang/test/SemaCXX/conditional-expr.cpp
@@ -409,3 +409,20 @@
D d = b ? D{B()} : D{C()};
}
}
+
+namespace PR46484 {
+// expected-error@+4{{expected ':'}}
+// expected-note@+3{{to match this '?'}}
+// expected-warning@+2{{variable 'b' is uninitialized}}
+// expected-error@+1 2 {{expected ';' after top level declarator}}
+int a long b = a = b ? throw 0 1
+
+void g() {
+ extern int a;
+ extern long b;
+ long c = a = b ? throw 0 : 1;
+ long d = a = b ? 1 : throw 0;
+ // expected-error@+1 {{assigning to 'int' from incompatible type 'void'}}
+ long e = a = b ? throw 0 : throw 1;
+}
+} // namespace PR46484
Index: clang/lib/Sema/SemaChecking.cpp
===================================================================
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -10308,10 +10308,16 @@
MaxWidth, InConstantContext);
// Otherwise, conservatively merge.
- IntRange L =
- GetExprRange(C, CO->getTrueExpr(), MaxWidth, InConstantContext);
- IntRange R =
- GetExprRange(C, CO->getFalseExpr(), MaxWidth, InConstantContext);
+ // GetExprRange requires an integer expression, but a throw expression
+ // results in a void type.
+ Expr *E = CO->getTrueExpr();
+ IntRange L = E->getType()->isVoidType()
+ ? IntRange{0, true}
+ : GetExprRange(C, E, MaxWidth, InConstantContext);
+ E = CO->getFalseExpr();
+ IntRange R = E->getType()->isVoidType()
+ ? IntRange{0, true}
+ : GetExprRange(C, E, MaxWidth, InConstantContext);
return IntRange::join(L, R);
}
Index: clang/test/SemaCXX/conditional-expr.cpp
===================================================================
--- clang/test/SemaCXX/conditional-expr.cpp
+++ clang/test/SemaCXX/conditional-expr.cpp
@@ -409,3 +409,20 @@
D d = b ? D{B()} : D{C()};
}
}
+
+namespace PR46484 {
+// expected-error@+4{{expected ':'}}
+// expected-note@+3{{to match this '?'}}
+// expected-warning@+2{{variable 'b' is uninitialized}}
+// expected-error@+1 2 {{expected ';' after top level declarator}}
+int a long b = a = b ? throw 0 1
+
+void g() {
+ extern int a;
+ extern long b;
+ long c = a = b ? throw 0 : 1;
+ long d = a = b ? 1 : throw 0;
+ // expected-error@+1 {{assigning to 'int' from incompatible type 'void'}}
+ long e = a = b ? throw 0 : throw 1;
+}
+} // namespace PR46484
Index: clang/lib/Sema/SemaChecking.cpp
===================================================================
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -10308,10 +10308,16 @@
MaxWidth, InConstantContext);
// Otherwise, conservatively merge.
- IntRange L =
- GetExprRange(C, CO->getTrueExpr(), MaxWidth, InConstantContext);
- IntRange R =
- GetExprRange(C, CO->getFalseExpr(), MaxWidth, InConstantContext);
+ // GetExprRange requires an integer expression, but a throw expression
+ // results in a void type.
+ Expr *E = CO->getTrueExpr();
+ IntRange L = E->getType()->isVoidType()
+ ? IntRange{0, true}
+ : GetExprRange(C, E, MaxWidth, InConstantContext);
+ E = CO->getFalseExpr();
+ IntRange R = E->getType()->isVoidType()
+ ? IntRange{0, true}
+ : GetExprRange(C, E, MaxWidth, InConstantContext);
return IntRange::join(L, R);
}
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits