Don't accept -std= values that would switch us to a different source language.

We already prohibited this in most cases (in r130710), but had some bugs in our
enforcement of this rule. Specifically, this prevents the following
combinations:

 * -x c -std=clN.M, which would previously effectively act as if -x cl were
   used, despite the input being a C source file. (-x cl -std=cNN continues
   to be disallowed.)

 * -x c++ -std=cuda, which would previously select C++98 + CUDA, despite that
   not being a C++ standard. (-x cuda -std=c++NN is still permitted, and
   selects CUDA with the given C++ standard as its base language.
   -x cuda -std=cuda is still supported with the meaning of CUDA + C++98.)

 * -x renderscript -std=c++NN, which would previously form a hybrid "C++ with
   RenderScript extensions" language. We could support such a thing, but
   shouldn't do so by accident.

llvm-svn: 301497
diff --git a/clang/test/Driver/unknown-std.cpp b/clang/test/Driver/unknown-std.cpp
index faeb2cb..0ffc1e2 100644
--- a/clang/test/Driver/unknown-std.cpp
+++ b/clang/test/Driver/unknown-std.cpp
@@ -2,8 +2,9 @@
 // When user selects invalid language standard
 // print out supported values with short description.
 
-// RUN: not %clang %s -std=foobar -c 2>&1 | \
-// RUN: FileCheck --match-full-lines %s
+// RUN: not %clang %s -std=foobar -c 2>&1 | FileCheck --match-full-lines %s
+// RUN: not %clang -x objective-c++ %s -std=foobar -c 2>&1 | FileCheck --match-full-lines %s
+// RUN: not %clang -x cuda -nocudainc -nocudalib %s -std=foobar -c 2>&1 | FileCheck --match-full-lines --check-prefix=CHECK --check-prefix=CUDA %s
 
 // CHECK: error: invalid value 'foobar' in '-std=foobar'
 // CHECK-NEXT: note: use 'c++98' for 'ISO C++ 1998 with amendments' standard
@@ -19,7 +20,7 @@
 // CHECK-NEXT: note: use 'gnu++14' for 'ISO C++ 2014 with amendments and GNU extensions' standard
 // CHECK-NEXT: note: use 'c++1z' for 'Working draft for ISO C++ 2017' standard
 // CHECK-NEXT: note: use 'gnu++1z' for 'Working draft for ISO C++ 2017 with GNU extensions' standard
-// CHECK-NEXT: note: use 'cuda' for 'NVIDIA CUDA(tm)' standard
+// CUDA-NEXT: note: use 'cuda' for 'NVIDIA CUDA(tm)' standard
 
 // Make sure that no other output is present.
 // CHECK-NOT: {{^.+$}}