]> granicus.if.org Git - clang/commitdiff
Fix a crash-on-invalid when parsing a reference to an invalid auto declaration
authorDavid Blaikie <dblaikie@gmail.com>
Wed, 10 Oct 2012 23:15:05 +0000 (23:15 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Wed, 10 Oct 2012 23:15:05 +0000 (23:15 +0000)
  auto x((unknown));
  int& y = x;

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165675 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 52bd4166bb89d28f9888384134da2ad542e6e3d5..3ef4f38ad034bea7a5860a045b6091bc76e27191 100644 (file)
@@ -1680,6 +1680,7 @@ Decl *Parser::ParseDeclarationAfterDeclaratorAndAttributes(Declarator &D,
     }
 
     if (ParseExpressionList(Exprs, CommaLocs)) {
+      Actions.ActOnInitializerError(ThisDecl);
       SkipUntil(tok::r_paren);
 
       if (getLangOpts().CPlusPlus && D.getCXXScopeSpec().isSet()) {
index f732255a8a4f1350ecd138eb6903e84ab565fe56..e91cacf10466ca7eef587952c4d4ed21b8996be1 100644 (file)
@@ -86,3 +86,6 @@ namespace PR13293 {
   template void h<double>();
 }
 #endif
+
+auto fail((unknown)); // expected-error{{use of undeclared identifier 'unknown'}}
+int& crash = fail;
index 582701957e5942c95be0fc2415c6ac8668ab009d..8bf2560417adedd026eedd31edb2fc00f0058824 100644 (file)
@@ -42,10 +42,11 @@ void test_dependent_init(T *p) {
 }
 
 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>'}}
   }
 }