[clang] 09e7fe9 - [AST][RecoveryAST] Preserve the type by default for recovery expression.
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 24 05:33:47 PDT 2020
Author: Haojian Wu
Date: 2020-08-24T14:28:28+02:00
New Revision: 09e7fe9859b4efeeb35697c095c9676e993fc03c
URL: https://github.com/llvm/llvm-project/commit/09e7fe9859b4efeeb35697c095c9676e993fc03c
DIFF: https://github.com/llvm/llvm-project/commit/09e7fe9859b4efeeb35697c095c9676e993fc03c.diff
LOG: [AST][RecoveryAST] Preserve the type by default for recovery expression.
Differential Revision: https://reviews.llvm.org/D82657
Added:
Modified:
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CXX/temp/temp.constr/temp.constr.order/function-templates.cpp
clang/test/SemaCXX/abstract.cpp
clang/test/SemaCXX/decl-expr-ambiguity.cpp
clang/test/SemaCXX/recovery-expr-type.cpp
clang/test/SemaCXX/type-convert-construct.cpp
clang/test/SemaTemplate/dependent-names.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 44b1eb3c614e..111eec4b4a00 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4043,8 +4043,7 @@ def frecovery_ast : Flag<["-"], "frecovery-ast">,
"encountering semantic errors">;
def fno_recovery_ast : Flag<["-"], "fno-recovery-ast">;
def frecovery_ast_type : Flag<["-"], "frecovery-ast-type">,
- HelpText<"Preserve the type for recovery expressions when possible "
- "(experimental)">;
+ HelpText<"Preserve the type for recovery expressions when possible">;
def fno_recovery_ast_type : Flag<["-"], "fno-recovery-ast-type">;
let Group = Action_Group in {
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 477959f04c41..175985bd950a 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2934,8 +2934,8 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
// Recovery AST still heavily relies on dependent-type machinery.
Opts.RecoveryAST =
Args.hasFlag(OPT_frecovery_ast, OPT_fno_recovery_ast, Opts.CPlusPlus);
- Opts.RecoveryASTType =
- Args.hasFlag(OPT_frecovery_ast_type, OPT_fno_recovery_ast_type, false);
+ Opts.RecoveryASTType = Args.hasFlag(
+ OPT_frecovery_ast_type, OPT_fno_recovery_ast_type, Opts.CPlusPlus);
Opts.HeinousExtensions = Args.hasArg(OPT_fheinous_gnu_extensions);
Opts.AccessControl = !Args.hasArg(OPT_fno_access_control);
Opts.ElideConstructors = !Args.hasArg(OPT_fno_elide_constructors);
diff --git a/clang/test/CXX/temp/temp.constr/temp.constr.order/function-templates.cpp b/clang/test/CXX/temp/temp.constr/temp.constr.order/function-templates.cpp
index 8ae630871445..b2fe2cd52006 100644
--- a/clang/test/CXX/temp/temp.constr/temp.constr.order/function-templates.cpp
+++ b/clang/test/CXX/temp/temp.constr/temp.constr.order/function-templates.cpp
@@ -67,7 +67,8 @@ void f() { }
// expected-note at -1 {{candidate function [with T = long long, U = int]}}
static_assert(sizeof(f<long long, int>()));
-// expected-error at -1 {{call to 'f' is ambiguous}}
+// expected-error at -1 {{call to 'f' is ambiguous}} \
+ expected-error at -1 {{invalid application of 'sizeof' to an incomplete type 'void'}}
template<typename T>
concept C3 = true;
diff --git a/clang/test/SemaCXX/abstract.cpp b/clang/test/SemaCXX/abstract.cpp
index 1fda21caea49..c6ee3c6e4b86 100644
--- a/clang/test/SemaCXX/abstract.cpp
+++ b/clang/test/SemaCXX/abstract.cpp
@@ -279,7 +279,7 @@ namespace pr12658 {
virtual void f() = 0; // expected-note {{unimplemented pure virtual method 'f' in 'C'}}
};
- void foo( C& c ) {}
+ void foo(const C& c ) {}
void bar( void ) {
foo(C(99)); // expected-error {{allocating an object of abstract class type 'pr12658::C'}}
diff --git a/clang/test/SemaCXX/decl-expr-ambiguity.cpp b/clang/test/SemaCXX/decl-expr-ambiguity.cpp
index b77e226b5d01..a15ec397b4ae 100644
--- a/clang/test/SemaCXX/decl-expr-ambiguity.cpp
+++ b/clang/test/SemaCXX/decl-expr-ambiguity.cpp
@@ -12,7 +12,7 @@ void f() {
T(a)->m = 7;
int(a)++; // expected-error {{assignment to cast is illegal}}
__extension__ int(a)++; // expected-error {{assignment to cast is illegal}}
- __typeof(int)(a,5)<<a; // expected-error {{excess elements in scalar initializer}}
+ __typeof(int)(a,5)<<a; // expected-error {{excess elements in scalar initializer}} expected-warning {{expression result unused}}
void(a), ++a;
if (int(a)+1) {}
for (int(a)+1;;) {} // expected-warning {{expression result unused}}
diff --git a/clang/test/SemaCXX/recovery-expr-type.cpp b/clang/test/SemaCXX/recovery-expr-type.cpp
index 7fad61e53df8..075d0147c684 100644
--- a/clang/test/SemaCXX/recovery-expr-type.cpp
+++ b/clang/test/SemaCXX/recovery-expr-type.cpp
@@ -86,3 +86,22 @@ void func() {
(T(T())); // expected-error {{call to deleted constructor}}
}
}
+
+// verify the secondary diagnostic "no matching function" is emitted.
+namespace test7 {
+struct C {
+ C() = delete; // expected-note {{has been explicitly marked deleted}}
+};
+void f(C &); // expected-note {{candidate function not viable: expects an l-value for 1st argument}}
+void test() {
+ f(C()); // expected-error {{call to deleted constructor}} \
+ expected-error {{no matching function for call}}
+}
+}
+
+// verify the secondary diagnostic "cannot initialize" is emitted.
+namespace test8 {
+typedef int arr[];
+int v = arr(); // expected-error {{array types cannot be value-initialized}} \
+ expected-error {{cannot initialize a variable of type 'int' with an rvalue of type 'test8::arr'}}
+}
diff --git a/clang/test/SemaCXX/type-convert-construct.cpp b/clang/test/SemaCXX/type-convert-construct.cpp
index 98e960727be2..3db49cffa231 100644
--- a/clang/test/SemaCXX/type-convert-construct.cpp
+++ b/clang/test/SemaCXX/type-convert-construct.cpp
@@ -6,7 +6,7 @@ void f() {
float v1 = float(1);
int v2 = typeof(int)(1,2); // expected-error {{excess elements in scalar initializer}}
typedef int arr[];
- int v3 = arr(); // expected-error {{array types cannot be value-initialized}}
+ arr(); // expected-error {{array types cannot be value-initialized}}
typedef void fn_ty();
fn_ty(); // expected-error {{cannot create object of function type 'fn_ty'}}
fn_ty(0); // expected-error {{functional-style cast from 'int' to 'fn_ty'}}
diff --git a/clang/test/SemaTemplate/dependent-names.cpp b/clang/test/SemaTemplate/dependent-names.cpp
index a8de159a1d46..689398cb2739 100644
--- a/clang/test/SemaTemplate/dependent-names.cpp
+++ b/clang/test/SemaTemplate/dependent-names.cpp
@@ -173,7 +173,7 @@ namespace PR10053 {
namespace O {
- void f(char&); // expected-note {{candidate function not viable}}
+ int f(char&); // expected-note {{candidate function not viable}}
template<typename T> struct C {
static const int n = f(T()); // expected-error {{no matching function}}
More information about the cfe-commits
mailing list