[PATCH] D82657: [AST][RecoveryAST] Preserve the type by default for recovery expression.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 12 00:51:30 PDT 2020


hokein updated this revision to Diff 284995.
hokein added a comment.

rebase and adjust more existing diagnostic tests.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82657/new/

https://reviews.llvm.org/D82657

Files:
  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/type-convert-construct.cpp
  clang/test/SemaTemplate/dependent-names.cpp


Index: clang/test/SemaTemplate/dependent-names.cpp
===================================================================
--- clang/test/SemaTemplate/dependent-names.cpp
+++ clang/test/SemaTemplate/dependent-names.cpp
@@ -173,7 +173,7 @@
 
 
   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}}
Index: clang/test/SemaCXX/type-convert-construct.cpp
===================================================================
--- clang/test/SemaCXX/type-convert-construct.cpp
+++ clang/test/SemaCXX/type-convert-construct.cpp
@@ -6,7 +6,8 @@
   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}}
+  int v3 = arr(); // expected-error {{array types cannot be value-initialized}} \
+                     expected-error {{cannot initialize a variable of type 'int' with an rvalue of type 'arr'}}
   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'}}
Index: clang/test/SemaCXX/decl-expr-ambiguity.cpp
===================================================================
--- clang/test/SemaCXX/decl-expr-ambiguity.cpp
+++ clang/test/SemaCXX/decl-expr-ambiguity.cpp
@@ -12,7 +12,7 @@
   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-error {{expression result unused}}
   void(a), ++a;
   if (int(a)+1) {}
   for (int(a)+1;;) {} // expected-warning {{expression result unused}}
Index: clang/test/SemaCXX/abstract.cpp
===================================================================
--- clang/test/SemaCXX/abstract.cpp
+++ clang/test/SemaCXX/abstract.cpp
@@ -279,10 +279,11 @@
       virtual void f() = 0; // expected-note {{unimplemented pure virtual method 'f' in 'C'}}
   };
 
-  void foo( C& c ) {}
+  void foo( C& c ) {} // expected-note {{candidate function not viable: expects an l-value for 1st argument}}
 
   void bar( void ) {
-    foo(C(99)); // expected-error {{allocating an object of abstract class type 'pr12658::C'}}
+    foo(C(99)); // expected-error {{allocating an object of abstract class type 'pr12658::C'}} \
+                   expected-error {{no matching function for call to 'foo'}}
   }
 }
 
Index: clang/test/CXX/temp/temp.constr/temp.constr.order/function-templates.cpp
===================================================================
--- clang/test/CXX/temp/temp.constr/temp.constr.order/function-templates.cpp
+++ clang/test/CXX/temp/temp.constr/temp.constr.order/function-templates.cpp
@@ -67,7 +67,8 @@
 // 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;
Index: clang/lib/Frontend/CompilerInvocation.cpp
===================================================================
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2926,8 +2926,8 @@
   // 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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82657.284995.patch
Type: text/x-patch
Size: 4306 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200812/b7a047b1/attachment.bin>


More information about the cfe-commits mailing list