summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-04-17 22:04:20 +0000
committerChris Lattner <sabre@nondot.org>2009-04-17 22:04:20 +0000
commit2581fc3fa98e369cce35684a576ec59cb7cabe83 (patch)
treeffd875e37175b652de0af7f018198b184f94c533 /clang/test
parentba6e55737825046a5e1dff82d54a0745f11c0796 (diff)
downloadbcm5719-llvm-2581fc3fa98e369cce35684a576ec59cb7cabe83.tar.gz
bcm5719-llvm-2581fc3fa98e369cce35684a576ec59cb7cabe83.zip
tweak redefinition of a typedef a bit to fix a couple of problems:
1. We had logic in sema to decide whether or not to emit the error based on manually checking whether in a system header file. 2. we were allowing redefinitions of typedefs in class scope in C++ if in header file. 3. there was no way to force typedef redefinitions to be accepted by the C compiler, which annoys me when stripping linemarkers out of .i files. The fix is to split the C++ class typedef redefinition path from the C path, and change the C path to be a warning that normally maps to error. This causes it to properly be ignored in system headers, etc. and gives us a way to control it. Passing -Wtypedef-redefinition now turns the error into a warning. One behavior change is that we now diagnose cases where you redefine a typedef in your .c file that was defined in a header file. This seems like reasonable behavior, and the diagnostic now indicates that it can be controlled with -Wtypedef-redefinition. llvm-svn: 69391
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/Preprocessor/line-directive.c4
-rw-r--r--clang/test/Sema/typedef-redef.c6
2 files changed, 2 insertions, 8 deletions
diff --git a/clang/test/Preprocessor/line-directive.c b/clang/test/Preprocessor/line-directive.c
index 07cfa65e946..66efae94d5c 100644
--- a/clang/test/Preprocessor/line-directive.c
+++ b/clang/test/Preprocessor/line-directive.c
@@ -40,7 +40,7 @@
# 192 "glomp.h" // not a system header.
typedef int x; // expected-note {{previous definition is here}}
-typedef int x; // expected-error {{redefinition of 'x'}}
+typedef int x; // expected-error {{redefinition of typedef 'x' is invalid in C}}
# 192 "glomp.h" 3 // System header.
typedef int y; // ok
@@ -59,4 +59,4 @@ typedef int z1; // ok
# 42 "blonk.h" // DOES change system headerness.
typedef int w; // expected-note {{previous definition is here}}
-typedef int w; // expected-error {{redefinition of 'w'}}
+typedef int w; // expected-error {{redefinition of typedef 'w' is invalid in C}}
diff --git a/clang/test/Sema/typedef-redef.c b/clang/test/Sema/typedef-redef.c
index 9ec622612ec..9a1c4887324 100644
--- a/clang/test/Sema/typedef-redef.c
+++ b/clang/test/Sema/typedef-redef.c
@@ -1,11 +1,5 @@
// RUN: clang-cc -fsyntax-only -verify %s
-// size_t coming from a system header.
-#include <stddef.h>
-typedef __SIZE_TYPE__ size_t;
-
-
-
typedef const int x; // expected-note {{previous definition is here}}
extern x a;
typedef int x; // expected-error {{typedef redefinition with different types}}
OpenPOWER on IntegriCloud