summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2011-10-20 03:28:47 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2011-10-20 03:28:47 +0000
commit91c7bbde4b6d8b916a81c66465951eda3684746c (patch)
tree0fb400c703e9f7ce23c0fda872328be6f331e983
parentf0bb0c2934565faecda1ed27eced70976b05fc4a (diff)
downloadbcm5719-llvm-91c7bbde4b6d8b916a81c66465951eda3684746c.tar.gz
bcm5719-llvm-91c7bbde4b6d8b916a81c66465951eda3684746c.zip
Add -Wc++98-compat warning for enumerations in nested name specifiers.
llvm-svn: 142568
-rw-r--r--clang/include/clang/Basic/DiagnosticSemaKinds.td3
-rw-r--r--clang/lib/Sema/SemaCXXScopeSpec.cpp3
-rw-r--r--clang/lib/Sema/TreeTransform.h3
-rw-r--r--clang/test/SemaCXX/cxx98-compat.cpp6
4 files changed, 15 insertions, 0 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 8c70572a740..f2fb998d8a3 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -833,6 +833,9 @@ def err_incomplete_member_access : Error<
"member access into incomplete type %0">;
def err_incomplete_type : Error<
"incomplete type %0 where a complete type is required">;
+def warn_cxx98_compat_enum_nested_name_spec : Warning<
+ "enumeration type in nested name specifier is incompatible with C++98">,
+ InGroup<CXX98Compat>, DefaultIgnore;
// C++ class members
def err_storageclass_invalid_for_member : Error<
diff --git a/clang/lib/Sema/SemaCXXScopeSpec.cpp b/clang/lib/Sema/SemaCXXScopeSpec.cpp
index a9b6536e7dc..dfd59bfe4fd 100644
--- a/clang/lib/Sema/SemaCXXScopeSpec.cpp
+++ b/clang/lib/Sema/SemaCXXScopeSpec.cpp
@@ -596,6 +596,9 @@ bool Sema::BuildCXXNestedNameSpecifier(Scope *S,
llvm_unreachable("Unhandled TypeDecl node in nested-name-specifier");
}
+ if (T->isEnumeralType())
+ Diag(IdentifierLoc, diag::warn_cxx98_compat_enum_nested_name_spec);
+
SS.Extend(Context, SourceLocation(), TLB.getTypeLocInContext(Context, T),
CCLoc);
return false;
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 64315ea15d0..03a1d78aa01 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -2629,6 +2629,9 @@ TreeTransform<Derived>::TransformNestedNameSpecifierLoc(
TL.getType()->isEnumeralType())) {
assert(!TL.getType().hasLocalQualifiers() &&
"Can't get cv-qualifiers here");
+ if (TL.getType()->isEnumeralType())
+ SemaRef.Diag(TL.getBeginLoc(),
+ diag::warn_cxx98_compat_enum_nested_name_spec);
SS.Extend(SemaRef.Context, /*FIXME:*/SourceLocation(), TL,
Q.getLocalEndLoc());
break;
diff --git a/clang/test/SemaCXX/cxx98-compat.cpp b/clang/test/SemaCXX/cxx98-compat.cpp
index 6d3abe85376..260e86b0ece 100644
--- a/clang/test/SemaCXX/cxx98-compat.cpp
+++ b/clang/test/SemaCXX/cxx98-compat.cpp
@@ -237,3 +237,9 @@ namespace UnionOrAnonStructMembers {
};
};
}
+
+int EnumNNS = Enum::enum_val; // expected-warning {{enumeration type in nested name specifier is incompatible with C++98}}
+template<typename T> void EnumNNSFn() {
+ int k = T::enum_val; // expected-warning {{enumeration type in nested name specifier is incompatible with C++98}}
+};
+template void EnumNNSFn<Enum>(); // expected-note {{in instantiation}}
OpenPOWER on IntegriCloud