[cfe-commits] r165675 - in /cfe/trunk: lib/Parse/ParseDecl.cpp test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp test/SemaCXX/warn-unused-variables.cpp

David Blaikie dblaikie at gmail.com
Wed Oct 10 16:15:06 PDT 2012


Author: dblaikie
Date: Wed Oct 10 18:15:05 2012
New Revision: 165675

URL: http://llvm.org/viewvc/llvm-project?rev=165675&view=rev
Log:
Fix a crash-on-invalid when parsing a reference to an invalid auto declaration

  auto x((unknown));
  int& y = x;

would crash because we were not flagging 'x' as an invalid declaration here.

Modified:
    cfe/trunk/lib/Parse/ParseDecl.cpp
    cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp
    cfe/trunk/test/SemaCXX/warn-unused-variables.cpp

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=165675&r1=165674&r2=165675&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Wed Oct 10 18:15:05 2012
@@ -1680,6 +1680,7 @@
     }
 
     if (ParseExpressionList(Exprs, CommaLocs)) {
+      Actions.ActOnInitializerError(ThisDecl);
       SkipUntil(tok::r_paren);
 
       if (getLangOpts().CPlusPlus && D.getCXXScopeSpec().isSet()) {

Modified: cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp?rev=165675&r1=165674&r2=165675&view=diff
==============================================================================
--- cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp (original)
+++ cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp Wed Oct 10 18:15:05 2012
@@ -86,3 +86,6 @@
   template void h<double>();
 }
 #endif
+
+auto fail((unknown)); // expected-error{{use of undeclared identifier 'unknown'}}
+int& crash = fail;

Modified: cfe/trunk/test/SemaCXX/warn-unused-variables.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-unused-variables.cpp?rev=165675&r1=165674&r2=165675&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-unused-variables.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-unused-variables.cpp Wed Oct 10 18:15:05 2012
@@ -42,10 +42,11 @@
 }
 
 namespace PR6948 {
-  template<typename T> class X;
+  template<typename T> class X; // expected-note{{template is declared here}}
   
   void f() {
-    X<char> str (read_from_file()); // expected-error{{use of undeclared identifier 'read_from_file'}}
+    X<char> str (read_from_file()); // expected-error{{use of undeclared identifier 'read_from_file'}} \
+                                       expected-error{{implicit instantiation of undefined template 'PR6948::X<char>'}}
   }
 }
 





More information about the cfe-commits mailing list